Re: [Rails] Auto refresh the drop-down
On Oct 10, 2012, at 7:59 PM, Jim Ruther Nill wrote:
>
>
> On Thu, Oct 11, 2012 at 7:47 AM, Walter Lee Davis <waltd@wdstudio.com> wrote:
>
> 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.
>
> I didn't really study js so there may be things that I don't know about. What's wrong with appending options to a select tag?
> I did some experimenting using jsfiddle and jquery. It turned out ok when I append options to a select tag.
>
> http://jsfiddle.net/w2UKY/
>
That clearly works in Safari 6, I wouldn't bet on it working in IE < 10.
Walter
>
> 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.
>
>
>
>
>
> --
> -------------------------------------------------------------
> visit my blog at http://jimlabs.heroku.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