Hi I''d like to do nested select controls, where the options in one select are based on the select value of another, kind of like http://www.pengoworks.com/qforms/docs/examples/n-related_selectboxes.htm Anyone ideas ? Erik
Erik Eide wrote:> Hi > > I''d like to do nested select controls, where the options in one select > are based on the select value of another, kind of like > http://www.pengoworks.com/qforms/docs/examples/n-related_selectboxes.htm > > Anyone ideas ? > > Erik > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > >Hi, You can either do it the way that it''s done on the link you send, by holding all data client side and then populating one list based on the selection of another by javascript. Or, you could go the other traditional way and do a page refresh, i.e. show the first listbox, get the selection and submit the format which will then come back with another listbox populated. Or, you could use ajax and basically do the same as the second approach but not do a full page refresh and instead just refresh the listboxes that you are interested in. Chris
Hi slightly off-topic but you may have an answer stil : which method do you use for internationalised select controls ? (there are probably plenty, I''m trying to get various advices!) Thibaut 2005/8/25, Chris Roos <chris-zoUjy1rb4AnQXOPxS62xeg@public.gmane.org>:> > Erik Eide wrote: > > Hi > > > > I''d like to do nested select controls, where the options in one select > > are based on the select value of another, kind of like > > http://www.pengoworks.com/qforms/docs/examples/n-related_selectboxes.htm > > > > Anyone ideas ? > > > > Erik > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > Hi, > > You can either do it the way that it''s done on the link you send, by > holding all data client side and then populating one list based on the > selection of another by javascript. > > Or, you could go the other traditional way and do a page refresh, i.e. > show the first listbox, get the selection and submit the format which > will then come back with another listbox populated. > > Or, you could use ajax and basically do the same as the second approach > but not do a full page refresh and instead just refresh the listboxes > that you are interested in. > > Chris > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- [blog] http://www.dotnetguru2.org/tbarrere _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Hi Thibaut, Not sure whether that''s a question to me directly but if so I''ve never had to internationalize an app and have therefore not come across the situation you describe. Sorry. Chris Thibaut Barrère wrote:> Hi > > slightly off-topic but you may have an answer stil : which method do you > use for internationalised select controls ? (there are probably plenty, > I''m trying to get various advices!) > > > Thibaut > > 2005/8/25, Chris Roos <chris-zoUjy1rb4AnQXOPxS62xeg@public.gmane.org <mailto:chris-zoUjy1rb4AnQXOPxS62xeg@public.gmane.org>>: > > Erik Eide wrote: > > Hi > > > > I''d like to do nested select controls, where the options in one > select > > are based on the select value of another, kind of like > > > http://www.pengoworks.com/qforms/docs/examples/n-related_selectboxes.htm > > > > Anyone ideas ? > > > > Erik > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org <mailto:Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org> > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > Hi, > > You can either do it the way that it''s done on the link you send, by > holding all data client side and then populating one list based on the > selection of another by javascript. > > Or, you could go the other traditional way and do a page refresh, i.e. > show the first listbox, get the selection and submit the format which > will then come back with another listbox populated. > > Or, you could use ajax and basically do the same as the second approach > but not do a full page refresh and instead just refresh the listboxes > that you are interested in. > > Chris > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org <mailto:Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org> > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > -- > [blog] http://www.dotnetguru2.org/tbarrere > > > ------------------------------------------------------------------------ > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails
I went the Ajax approach, but I''m stuck trying to get the value of the selected option to pass to the method. The last thing I tried was something like this, which rails reports an error that it can''t find ''this'', <td> <select onChange=''<%= remote_function(:update => ''select_div'', :url => { :controller => ''trade'', :action=> ''select_group'', :id => escape(this.options[this.selectedIndex].value) }) %>''> <%= options_from_collection_for_select(@groups, "id", "name") %> </td> <td> <div id="select_div"> <%= render_partial "trades_select" %> </div> </td> On 8/25/05, Chris Roos <chris-zoUjy1rb4AnQXOPxS62xeg@public.gmane.org> wrote:> Hi Thibaut, > > Not sure whether that''s a question to me directly but if so I''ve never > had to internationalize an app and have therefore not come across the > situation you describe. Sorry. > > Chris > > Thibaut Barrère wrote: > > Hi > > > > slightly off-topic but you may have an answer stil : which method do you > > use for internationalised select controls ? (there are probably plenty, > > I''m trying to get various advices!) > > > > > > Thibaut > > > > 2005/8/25, Chris Roos <chris-zoUjy1rb4AnQXOPxS62xeg@public.gmane.org <mailto:chris-zoUjy1rb4AnQXOPxS62xeg@public.gmane.org>>: > > > > Erik Eide wrote: > > > Hi > > > > > > I''d like to do nested select controls, where the options in one > > select > > > are based on the select value of another, kind of like > > > > > http://www.pengoworks.com/qforms/docs/examples/n-related_selectboxes.htm > > > > > > Anyone ideas ? > > > > > > Erik > > > _______________________________________________ > > > Rails mailing list > > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org <mailto:Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org> > > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > > > > Hi, > > > > You can either do it the way that it''s done on the link you send, by > > holding all data client side and then populating one list based on the > > selection of another by javascript. > > > > Or, you could go the other traditional way and do a page refresh, i.e. > > show the first listbox, get the selection and submit the format which > > will then come back with another listbox populated. > > > > Or, you could use ajax and basically do the same as the second approach > > but not do a full page refresh and instead just refresh the listboxes > > that you are interested in. > > > > Chris > > > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org <mailto:Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org> > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > > > > -- > > [blog] http://www.dotnetguru2.org/tbarrere > > > > > > ------------------------------------------------------------------------ > > > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Try using :with as a param to remote_function, rather than using :id in the :url. I''m using with to pass multiple parameters the same way as you talk about below. You should end up with something like. <%remote_function(:update => ''select_div'', :url => { :controller => ''trade'', :action => ''select_group'' }, :with => "''id='' + this.value") %> I''m not referring to this, rather I''m using $() to refer to another element on the form but it should work the same way. Chris Erik Eide wrote:> I went the Ajax approach, but I''m stuck trying to get the value of the > selected option to pass to the method. > > The last thing I tried was something like this, which rails reports an > error that it can''t find ''this'', > > <td> > <select onChange=''<%= remote_function(:update => ''select_div'', > :url => { :controller => ''trade'', :action=> > ''select_group'', :id => escape(this.options[this.selectedIndex].value) }) %>''> > <%= options_from_collection_for_select(@groups, "id", "name") %> > </td> > <td> > <div id="select_div"> > <%= render_partial "trades_select" %> > </div> > </td> > > On 8/25/05, Chris Roos <chris-zoUjy1rb4AnQXOPxS62xeg@public.gmane.org> wrote: > >>Hi Thibaut, >> >>Not sure whether that''s a question to me directly but if so I''ve never >>had to internationalize an app and have therefore not come across the >>situation you describe. Sorry. >> >>Chris >> >>Thibaut Barrère wrote: >> >>>Hi >>> >>>slightly off-topic but you may have an answer stil : which method do you >>>use for internationalised select controls ? (there are probably plenty, >>>I''m trying to get various advices!) >>> >>> >>>Thibaut >>> >>>2005/8/25, Chris Roos <chris-zoUjy1rb4AnQXOPxS62xeg@public.gmane.org <mailto:chris-zoUjy1rb4AnQXOPxS62xeg@public.gmane.org>>: >>> >>> Erik Eide wrote: >>> > Hi >>> > >>> > I''d like to do nested select controls, where the options in one >>> select >>> > are based on the select value of another, kind of like >>> > >>> http://www.pengoworks.com/qforms/docs/examples/n-related_selectboxes.htm >>> > >>> > Anyone ideas ? >>> > >>> > Erik >>> > _______________________________________________ >>> > Rails mailing list >>> > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org <mailto:Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org> >>> > http://lists.rubyonrails.org/mailman/listinfo/rails >>> > >>> > >>> >>> Hi, >>> >>> You can either do it the way that it''s done on the link you send, by >>> holding all data client side and then populating one list based on the >>> selection of another by javascript. >>> >>> Or, you could go the other traditional way and do a page refresh, i.e. >>> show the first listbox, get the selection and submit the format which >>> will then come back with another listbox populated. >>> >>> Or, you could use ajax and basically do the same as the second approach >>> but not do a full page refresh and instead just refresh the listboxes >>> that you are interested in. >>> >>> Chris >>> >>> _______________________________________________ >>> Rails mailing list >>> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org <mailto:Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org> >>> http://lists.rubyonrails.org/mailman/listinfo/rails >>> >>> >>> >>> >>>-- >>>[blog] http://www.dotnetguru2.org/tbarrere >>> >>> >>>------------------------------------------------------------------------ >>> >>>_______________________________________________ >>>Rails mailing list >>>Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >>>http://lists.rubyonrails.org/mailman/listinfo/rails >> >> >>_______________________________________________ >>Rails mailing list >>Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >>http://lists.rubyonrails.org/mailman/listinfo/rails >> > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > >
Thanks Chris That worked really well On 8/25/05, Chris Roos <chris-zoUjy1rb4AnQXOPxS62xeg@public.gmane.org> wrote:> Try using :with as a param to remote_function, rather than using :id in > the :url. I''m using with to pass multiple parameters the same way as > you talk about below. You should end up with something like. > > <%> remote_function(:update => ''select_div'', > :url => { :controller => ''trade'', > :action => ''select_group'' }, > :with => "''id='' + this.value") > %> > > I''m not referring to this, rather I''m using $() to refer to another > element on the form but it should work the same way. > > Chris > > Erik Eide wrote: > > I went the Ajax approach, but I''m stuck trying to get the value of the > > selected option to pass to the method. > > > > The last thing I tried was something like this, which rails reports an > > error that it can''t find ''this'', > > > > <td> > > <select onChange=''<%= remote_function(:update => ''select_div'', > > :url => { :controller => ''trade'', :action=> > > ''select_group'', :id => escape(this.options[this.selectedIndex].value) }) %>''> > > <%= options_from_collection_for_select(@groups, "id", "name") %> > > </td> > > <td> > > <div id="select_div"> > > <%= render_partial "trades_select" %> > > </div> > > </td> > > > > On 8/25/05, Chris Roos <chris-zoUjy1rb4AnQXOPxS62xeg@public.gmane.org> wrote: > > > >>Hi Thibaut, > >> > >>Not sure whether that''s a question to me directly but if so I''ve never > >>had to internationalize an app and have therefore not come across the > >>situation you describe. Sorry. > >> > >>Chris > >> > >>Thibaut Barrère wrote: > >> > >>>Hi > >>> > >>>slightly off-topic but you may have an answer stil : which method do you > >>>use for internationalised select controls ? (there are probably plenty, > >>>I''m trying to get various advices!) > >>> > >>> > >>>Thibaut > >>> > >>>2005/8/25, Chris Roos <chris-zoUjy1rb4AnQXOPxS62xeg@public.gmane.org <mailto:chris-zoUjy1rb4AnQXOPxS62xeg@public.gmane.org>>: > >>> > >>> Erik Eide wrote: > >>> > Hi > >>> > > >>> > I''d like to do nested select controls, where the options in one > >>> select > >>> > are based on the select value of another, kind of like > >>> > > >>> http://www.pengoworks.com/qforms/docs/examples/n-related_selectboxes.htm > >>> > > >>> > Anyone ideas ? > >>> > > >>> > Erik > >>> > _______________________________________________ > >>> > Rails mailing list > >>> > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org <mailto:Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org> > >>> > http://lists.rubyonrails.org/mailman/listinfo/rails > >>> > > >>> > > >>> > >>> Hi, > >>> > >>> You can either do it the way that it''s done on the link you send, by > >>> holding all data client side and then populating one list based on the > >>> selection of another by javascript. > >>> > >>> Or, you could go the other traditional way and do a page refresh, i.e. > >>> show the first listbox, get the selection and submit the format which > >>> will then come back with another listbox populated. > >>> > >>> Or, you could use ajax and basically do the same as the second approach > >>> but not do a full page refresh and instead just refresh the listboxes > >>> that you are interested in. > >>> > >>> Chris > >>> > >>> _______________________________________________ > >>> Rails mailing list > >>> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org <mailto:Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org> > >>> http://lists.rubyonrails.org/mailman/listinfo/rails > >>> > >>> > >>> > >>> > >>>-- > >>>[blog] http://www.dotnetguru2.org/tbarrere > >>> > >>> > >>>------------------------------------------------------------------------ > >>> > >>>_______________________________________________ > >>>Rails mailing list > >>>Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > >>>http://lists.rubyonrails.org/mailman/listinfo/rails > >> > >> > >>_______________________________________________ > >>Rails mailing list > >>Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > >>http://lists.rubyonrails.org/mailman/listinfo/rails > >> > > > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Hi, I too, am in need of a select list solution like this. So I thought i''d just take what had been discussed in this thread and put it to work. Made some changes and decided to give it a go. But no luck. I am not even getting any requests sent back to the server. <%= select(''invoice'', ''project_id'', @projects.collect { |p| [ p.name, p.id] }, { :prompt => true }, { ''onChange'' => remote_function(:update => ''tasks'', :url => { :controller => ''/manager/invoice'', :action => ''tasks'' })} ) %> <div id="tasks"></div> I tried using observe_field too, but that didn''t work too well either. Is there something wrong there that I just can''t see? And in the controller the action ''tasks'' just returns render :text => ''test'' Dylan.> Try using :with as a param to remote_function, rather than using :id > in the :url. I''m using with to pass multiple parameters the same way > as you talk about below. You should end up with something like. > > <%> remote_function(:update => ''select_div'', > :url => { :controller => ''trade'', > :action => ''select_group'' }, > :with => "''id='' + this.value") > %> > > I''m not referring to this, rather I''m using $() to refer to another > element on the form but it should work the same way. > > Chris
Is the /manager/invoice/tasks action definitely not being hit? You should see it being called in the output of webrick if that''s how you are developing. If it''s not being called do you have the prototype javascript libraries referenced? Have you tried calling manager/invoice/tasks manually (as a url) to check that the text is being output as expected? At this stage, if your action is not being called I''d suspect the js libs not being referenced. Let me know how you get on with the above and we can take it from there if it''s still not working. Chris Dylan Egan wrote:> Hi, > > I too, am in need of a select list solution like this. So I thought i''d > just take what had been discussed in this thread and put it to work. > Made some changes and decided to give it a go. But no luck. I am not > even getting any requests sent back to the server. > > <%= select(''invoice'', ''project_id'', @projects.collect { |p| [ p.name, > p.id] }, { :prompt => true }, > { ''onChange'' => remote_function(:update => ''tasks'', :url => { > :controller => ''/manager/invoice'', :action => ''tasks'' })} ) %> > <div id="tasks"></div> > > I tried using observe_field too, but that didn''t work too well either. > > Is there something wrong there that I just can''t see? > > And in the controller the action ''tasks'' just returns render :text => > ''test'' > > Dylan. > >> Try using :with as a param to remote_function, rather than using :id >> in the :url. I''m using with to pass multiple parameters the same way >> as you talk about below. You should end up with something like. >> >> <%>> remote_function(:update => ''select_div'', >> :url => { :controller => ''trade'', >> :action => ''select_group'' }, >> :with => "''id='' + this.value") >> %> >> >> I''m not referring to this, rather I''m using $() to refer to another >> element on the form but it should work the same way. >> >> Chris > > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > >
Heya Chris, You were right. As always nowadays for some reason I end up typing typo for type. So I was trying to call prototypo instead of prototype and I had a CSS include error too so I didn''t see it come up. Silly me. Thanks, Dylan> Is the /manager/invoice/tasks action definitely not being hit? You > should see it being called in the output of webrick if that''s how you > are developing. If it''s not being called do you have the prototype > javascript libraries referenced? Have you tried calling > manager/invoice/tasks manually (as a url) to check that the text is > being output as expected? > > At this stage, if your action is not being called I''d suspect the js > libs not being referenced. > > Let me know how you get on with the above and we can take it from > there if it''s still not working. > > Chris >
Chris How are you passing multiple parameters using the :with element ? I''d like to pass both an id as (works) below, but also a counter value - kind of like (which seems to cause a script error) <%= remote_function(:update => ''select_div'', :url => { :controller => ''trade'', :action => ''select_group'' }, :with => "''id='' + this.value, ''counter='' 1") %> On 8/25/05, Chris Roos <chris-zoUjy1rb4AnQXOPxS62xeg@public.gmane.org> wrote:> Try using :with as a param to remote_function, rather than using :id in > the :url. I''m using with to pass multiple parameters the same way as > you talk about below. You should end up with something like. > > <%> remote_function(:update => ''select_div'', > :url => { :controller => ''trade'', > :action => ''select_group'' }, > :with => "''id='' + this.value") > %> > > I''m not referring to this, rather I''m using $() to refer to another > element on the form but it should work the same way. > > Chris > > Erik Eide wrote: > > I went the Ajax approach, but I''m stuck trying to get the value of the > > selected option to pass to the method. > > > > The last thing I tried was something like this, which rails reports an > > error that it can''t find ''this'', > > > > <td> > > <select onChange=''<%= remote_function(:update => ''select_div'', > > :url => { :controller => ''trade'', :action=> > > ''select_group'', :id => escape(this.options[this.selectedIndex].value) }) %>''> > > <%= options_from_collection_for_select(@groups, "id", "name") %> > > </td> > > <td> > > <div id="select_div"> > > <%= render_partial "trades_select" %> > > </div> > > </td> > > > > On 8/25/05, Chris Roos <chris-zoUjy1rb4AnQXOPxS62xeg@public.gmane.org> wrote: > > > >>Hi Thibaut, > >> > >>Not sure whether that''s a question to me directly but if so I''ve never > >>had to internationalize an app and have therefore not come across the > >>situation you describe. Sorry. > >> > >>Chris > >> > >>Thibaut Barrère wrote: > >> > >>>Hi > >>> > >>>slightly off-topic but you may have an answer stil : which method do you > >>>use for internationalised select controls ? (there are probably plenty, > >>>I''m trying to get various advices!) > >>> > >>> > >>>Thibaut > >>> > >>>2005/8/25, Chris Roos <chris-zoUjy1rb4AnQXOPxS62xeg@public.gmane.org <mailto:chris-zoUjy1rb4AnQXOPxS62xeg@public.gmane.org>>: > >>> > >>> Erik Eide wrote: > >>> > Hi > >>> > > >>> > I''d like to do nested select controls, where the options in one > >>> select > >>> > are based on the select value of another, kind of like > >>> > > >>> http://www.pengoworks.com/qforms/docs/examples/n-related_selectboxes.htm > >>> > > >>> > Anyone ideas ? > >>> > > >>> > Erik > >>> > _______________________________________________ > >>> > Rails mailing list > >>> > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org <mailto:Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org> > >>> > http://lists.rubyonrails.org/mailman/listinfo/rails > >>> > > >>> > > >>> > >>> Hi, > >>> > >>> You can either do it the way that it''s done on the link you send, by > >>> holding all data client side and then populating one list based on the > >>> selection of another by javascript. > >>> > >>> Or, you could go the other traditional way and do a page refresh, i.e. > >>> show the first listbox, get the selection and submit the format which > >>> will then come back with another listbox populated. > >>> > >>> Or, you could use ajax and basically do the same as the second approach > >>> but not do a full page refresh and instead just refresh the listboxes > >>> that you are interested in. > >>> > >>> Chris > >>> > >>> _______________________________________________ > >>> Rails mailing list > >>> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org <mailto:Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org> > >>> http://lists.rubyonrails.org/mailman/listinfo/rails > >>> > >>> > >>> > >>> > >>>-- > >>>[blog] http://www.dotnetguru2.org/tbarrere > >>> > >>> > >>>------------------------------------------------------------------------ > >>> > >>>_______________________________________________ > >>>Rails mailing list > >>>Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > >>>http://lists.rubyonrails.org/mailman/listinfo/rails > >> > >> > >>_______________________________________________ > >>Rails mailing list > >>Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > >>http://lists.rubyonrails.org/mailman/listinfo/rails > >> > > > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
On 28.8.2005, at 0.57, Erik Eide wrote:> Chris > > How are you passing multiple parameters using the :with element ? I''d > like to pass both an id as (works) below, but also a counter value - > kind of like (which seems to cause a script error) > > <%= remote_function(:update => ''select_div'', > :url => { :controller => ''trade'', :action => ''select_group'' }, > :with => "''id='' + this.value, ''counter='' 1") > %>:with argument will be passed to the end of the url as such so you need to make it a valid query string. That means something like this: :with => "''id='' + this.value + ''&counter=1''" //jarkko -- Jarkko Laine http://jlaine.net http://odesign.fi _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Erik Eide wrote:> Chris > > How are you passing multiple parameters using the :with element ? I''d > like to pass both an id as (works) below, but also a counter value - > kind of like (which seems to cause a script error) > > <%= remote_function(:update => ''select_div'', > :url => { :controller => ''trade'', :action => ''select_group'' }, > :with => "''id='' + this.value, ''counter='' 1") > %> >Just building the querystring manually, something like. :with => "''id='' + this.value + ''&counter='' + $(counter_field).value" Chris> On 8/25/05, Chris Roos <chris-zoUjy1rb4AnQXOPxS62xeg@public.gmane.org> wrote: > >>Try using :with as a param to remote_function, rather than using :id in >>the :url. I''m using with to pass multiple parameters the same way as >>you talk about below. You should end up with something like. >> >><%>>remote_function(:update => ''select_div'', >> :url => { :controller => ''trade'', >> :action => ''select_group'' }, >> :with => "''id='' + this.value") >>%> >> >>I''m not referring to this, rather I''m using $() to refer to another >>element on the form but it should work the same way. >> >>Chris >> >>Erik Eide wrote: >> >>>I went the Ajax approach, but I''m stuck trying to get the value of the >>>selected option to pass to the method. >>> >>>The last thing I tried was something like this, which rails reports an >>>error that it can''t find ''this'', >>> >>> <td> >>> <select onChange=''<%= remote_function(:update => ''select_div'', >>> :url => { :controller => ''trade'', :action=> >>>''select_group'', :id => escape(this.options[this.selectedIndex].value) }) %>''> >>> <%= options_from_collection_for_select(@groups, "id", "name") %> >>> </td> >>> <td> >>> <div id="select_div"> >>> <%= render_partial "trades_select" %> >>> </div> >>> </td> >>> >>>On 8/25/05, Chris Roos <chris-zoUjy1rb4AnQXOPxS62xeg@public.gmane.org> wrote: >>> >>> >>>>Hi Thibaut, >>>> >>>>Not sure whether that''s a question to me directly but if so I''ve never >>>>had to internationalize an app and have therefore not come across the >>>>situation you describe. Sorry. >>>> >>>>Chris >>>> >>>>Thibaut Barrère wrote: >>>> >>>> >>>>>Hi >>>>> >>>>>slightly off-topic but you may have an answer stil : which method do you >>>>>use for internationalised select controls ? (there are probably plenty, >>>>>I''m trying to get various advices!) >>>>> >>>>> >>>>>Thibaut >>>>> >>>>>2005/8/25, Chris Roos <chris-zoUjy1rb4AnQXOPxS62xeg@public.gmane.org <mailto:chris-zoUjy1rb4AnQXOPxS62xeg@public.gmane.org>>: >>>>> >>>>> Erik Eide wrote: >>>>> > Hi >>>>> > >>>>> > I''d like to do nested select controls, where the options in one >>>>> select >>>>> > are based on the select value of another, kind of like >>>>> > >>>>> http://www.pengoworks.com/qforms/docs/examples/n-related_selectboxes.htm >>>>> > >>>>> > Anyone ideas ? >>>>> > >>>>> > Erik >>>>> > _______________________________________________ >>>>> > Rails mailing list >>>>> > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org <mailto:Rails-1W37MKcQCpIf0INCOvqR/r74wrMN1lrk@public.gmane.orgg> >>>>> > http://lists.rubyonrails.org/mailman/listinfo/rails >>>>> > >>>>> > >>>>> >>>>> Hi, >>>>> >>>>> You can either do it the way that it''s done on the link you send, by >>>>> holding all data client side and then populating one list based on the >>>>> selection of another by javascript. >>>>> >>>>> Or, you could go the other traditional way and do a page refresh, i.e. >>>>> show the first listbox, get the selection and submit the format which >>>>> will then come back with another listbox populated. >>>>> >>>>> Or, you could use ajax and basically do the same as the second approach >>>>> but not do a full page refresh and instead just refresh the listboxes >>>>> that you are interested in. >>>>> >>>>> Chris >>>>> >>>>> _______________________________________________ >>>>> Rails mailing list >>>>> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org <mailto:Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org> >>>>> http://lists.rubyonrails.org/mailman/listinfo/rails >>>>> >>>>> >>>>> >>>>> >>>>>-- >>>>>[blog] http://www.dotnetguru2.org/tbarrere >>>>> >>>>> >>>>>------------------------------------------------------------------------ >>>>> >>>>>_______________________________________________ >>>>>Rails mailing list >>>>>Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >>>>>http://lists.rubyonrails.org/mailman/listinfo/rails >>>> >>>> >>>>_______________________________________________ >>>>Rails mailing list >>>>Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >>>>http://lists.rubyonrails.org/mailman/listinfo/rails >>>> >>> >>>_______________________________________________ >>>Rails mailing list >>>Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >>>http://lists.rubyonrails.org/mailman/listinfo/rails >>> >>> >> >> >>_______________________________________________ >>Rails mailing list >>Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >>http://lists.rubyonrails.org/mailman/listinfo/rails >> > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > >