This works as expected, however instead of rendering a .rhtml I want to
use a rjs template, but how do I position the list shown by the
auto_complete… method?
e.g. def product
respond_to do | format |
format.html
format.js { render :action => "project.rjs" }
format.xml
end
end
Note: This will return the appropriate response based on
Hi, you can also find further information in section 12.1 of the ‘Agile
Web
Development with Rails 2ed’.
-Conrad
Hi Conrad,
Although respond_to is very interesting, this is not what I’m looking
for.
What I want is, when typing a character into an autocomplete textbox, I
also want to show a Save button, which is initially hidden.
Now I use this approach:
def show_save
render :update do |page|
page.show ‘save_div’
end
end
The Observe tag looks for changes in the autocomplete textbox and
triggers a method named show_save. The show_save method displays the
element named ‘save_div’ which containts the text ‘Show this later’.
This is working, however I wonder if this can be accomplished using 1
method named auto_complete_for_model_field which displays the
autocomplete list AND show the ‘save_div’ element.
One step futher (and a little off topic): After displaying de ‘save_div’
element I want the Observer to stop observing. I tried to nest the
observe_field into a div-element (say: ‘observe_div’) and let this be
removed when the show_save method is called:
def show_save
render :update do |page|
page.show ‘save_div’
page.remove ‘observe_div’
end
end
The element is deleted, but the textbox is still being observed.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.