jquery multiple select x rails edit action

Posted by VP on Stack Overflow See other posts from Stack Overflow or by VP
Published on 2010-04-27T08:05:30Z Indexed on 2010/04/27 10:13 UTC
Read the original article Hit count: 212

Filed under:
|
|
|

Hi,

i'm using the JQUERY multiselectable plugin. Because it's get one select box and transform it in two, where you can move one selected option to another select box. The problem is that i'm facing some problems with the edit action. When i load the form, the selected values (that are saved in my model) are not being populated in the "selected" select box. There is anybody with a good idea about how to "automatically" move the selected values in my database from the "available to be selected" to "selected" options?

For now i'm doing something like

<%= select "product", :option_ids, options_for_select(Option.all.map { |opt| [opt.description, opt.id]}), {},{:multiple=> true,:class=>'multiselect'} %>

Here i can see already the problem. I could just use as options_for_select just all options - the options that are already choosed in my model. The problem is how to update the select box with this information?

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about ruby-on-rails