Forum: Ruby on Rails Problem with an AJAX drop-down menu

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
foxxbat (Guest)
on 2006-03-27 21:08
Hi everyone,

I'm currently playing with ruby on rails, and I was trying to build a
form with limited AJAX functionalities...

So here is my problem : I want to create a form in order to allow
visitors to choose a car make and a car model. Once the user has choosen
his make in a select tag, the model select tag is supposed to be updated
with the models that belong to the choosen make (using an AJAX
observer).

The problem is that the model menu is updated (i use a partial to fill
the select tag with <option>s), but the html tags are missing, and the
models aren't selectable, nor are they separated since they're not
included between <option> and </option>.

I tried to replace the drop-down menu with a simple unordered list
(<ul>), updated and filled with <li> tags... and it works. Is there
something special about form tags?

Sorry if this isn't clear, i haven't practised my English for a while...

Thanks for your attention,

foxxbat
Thomas F. (Guest)
on 2006-03-27 21:29
(Received via mailing list)
You can't use plain HTML to update a <select>. You have to use
the API of the select element, or you might have luck replacing the
*entire*
select element (not just the options) with your partial.

So, yes, <select> is special.

-Thomas

Am 27.03.2006 um 19:08 schrieb foxxbat:
foxxbat (Guest)
on 2006-03-27 22:09
Thomas F. wrote:
> You can't use plain HTML to update a <select>. You have to use
> the API of the select element, or you might have luck replacing the
> *entire*
> select element (not just the options) with your partial.
>
> So, yes, <select> is special.
>
> -Thomas
>
> Am 27.03.2006 um 19:08 schrieb foxxbat:

Thanks a lot for the help. I have the same problem with the select API,
but it seems to work fine if i replace the entire select element.

foxxbat
This topic is locked and can not be replied to.