Wednesday, October 10, 2012

Re: [Rails] Auto refresh the drop-down

On Oct 10, 2012, at 4:07 PM, Ramesh C. wrote:

> Walter Davis wrote in post #1079286:
>> On Oct 10, 2012, at 2:13 PM, chandru c. wrote:
>>
>>>>>>
>>>>> rubyonrails-talk+unsubscribe@googlegroups.com.
>>> Jim,
>>> val2 = document.getElementById("item_id").value
>>> alert "Item saved" + msg.name
>>> "I guess here I have to add changes to make dropdown refresh"
>>
>> I'm not sure how this would translate into CS, but in vanilla JS, you
>> would do this to add a new option at the end of an existing select:
>>
>> var s = document.getElementById('your-select');
>> s.options[s.options.length] = new Option(label, value);
>> s.options.selectedIndex = s.options.length - 1;
>>
>> Whatever you do, resist the urge to use a jQuery update to write another
>> <option> into the <select> tag -- select tags resolutely do not work
>> that way, and you'll just go round and round until you work that out.
>>
>> Walter
>
>
> Hi Walter..
>
> It has to just update values from db. Refresh it using ajax.

You can replace the entire picker with Ajax, but you cannot add elements to an existing select on the page using Ajax. That was the only point I was trying to make.

Walter

>
> --
> Posted via http://www.ruby-forum.com/.
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate