Re: [Rails] Rails/JQuery Collection Select

2010-04-08 Thread Joshua Martin
Thanks Anthony! Your suggestion to use Rails' to_json method was right on target... I ended up creating a controller for the PhoneNumberCategory and added the to_json format on it's index method. This way, my JQuery script can do a JSON request and then dynamically create a select based on the res

Re: [Rails] Rails/JQuery Collection Select

2010-04-08 Thread Anthony Crumley
Joshua, Also consider using link_to_remote with the :update and :position options. Then you can keep all the view code on the server. Anthony Crumley On Thu, Apr 8, 2010 at 10:59 AM, Anthony Crumley wrote: > Joshua, > > BTW...I forgot to mention there is a to_json method you can probably use t

Re: [Rails] Rails/JQuery Collection Select

2010-04-08 Thread Anthony Crumley
Joshua, BTW...I forgot to mention there is a to_json method you can probably use to convert the @phone_number_categories collection to a Javascript value. Anthony Crumley On Thu, Apr 8, 2010 at 10:57 AM, Anthony Crumley wrote: > Joshua, > > You can't access that variable directly from jQuery be

Re: [Rails] Rails/JQuery Collection Select

2010-04-08 Thread Anthony Crumley
Joshua, You can't access that variable directly from jQuery because jQuery is Javascript running in the browser and @phone_number_categories is Ruby running on the server. If you want to do all this on the client side then you can save the categories into a Javascript variable that is in scope wi

[Rails] Rails/JQuery Collection Select

2010-04-08 Thread Joshua Martin
I may be asking a very dumb question, but I thought it'd be worth the asking.. I'm using JQuery to dynamically create some form fields for entering phone numbers... Basically just two fields.. One for the number, and a select field so that the user can choose whether it's a Home/Work/etc. number.