Hi, I''m trying to have a checkbox, that when clickes sends an update to the server and in turn modify the UI with feedback on the success of the operation. The main difficulty I''m encountering is that I can''t pass the checkbox value if I use the standard PrototypeHelpers. I''m using remote_function to build the function call, but it doesn''t allow me to pass the "this.checked" from the combo to the server. As far as I understand, the url should be written in the javascript as "/item/5/"+this.checked, but since the url is build only of options I can''t generate this. 1. How can this be done? 2. Why isn''t there checkbox_remote just like there is link_to_remote. I would expect this also for all controls (radio buttons, edit boxes, etc.) so maybe it is hiding there somewhere? 3. Any workaround using other methods or assistance how write my own checkbox_remote without duplicating too much existing rails code? (as I need to modify also the url_for to get this solved). I''d prefer to to simply generate the whols javascript myself - I''d rather use ruby methods for everything. Thanks, Ronen -- Posted via http://www.ruby-forum.com/.
I think what you want to use is a field observer. http://api.rubyonrails.com/classes/ActionView/Helpers/PrototypeHelper.html#M000421 It''s really easy, and has the same syntax as link_to_remote. -- Posted via http://www.ruby-forum.com/.
Bryan Duxbury wrote:> I think what you want to use is a field observer. > > http://api.rubyonrails.com/classes/ActionView/Helpers/PrototypeHelper.html#M000421 > > It''s really easy, and has the same syntax as link_to_remote.Not exactly since I want to have immediate response after the checkbox is pressed. Not one that is delayed. Ronen -- Posted via http://www.ruby-forum.com/.
Ronen Levi wrote:> Bryan Duxbury wrote: >> I think what you want to use is a field observer. >> >> http://api.rubyonrails.com/classes/ActionView/Helpers/PrototypeHelper.html#M000421 >> >> It''s really easy, and has the same syntax as link_to_remote. > > Not exactly since I want to have immediate response after the checkbox > is pressed. Not one that is delayed. > > Ronencorrect me if im wrong here like, but wouldnt you just set the frequency to 0, hence making it event based and doing what you want when the checkbox is clicked? like i said correct me if im wrong, but it seems pretty self-explanitory in the docs -- Posted via http://www.ruby-forum.com/.
Adam Holt wrote:> > correct me if im wrong here like, but wouldnt you just set the frequency > to 0, hence making it event based and doing what you want when the > checkbox is clicked? > > like i said correct me if im wrong, but it seems pretty self-explanitory > in the docsOops, didn''t notice the statement that 0 will take a different approach. Thanks - I''ll try that. -- Posted via http://www.ruby-forum.com/.
Ronen Levi wrote:> Adam Holt wrote: >> >> correct me if im wrong here like, but wouldnt you just set the frequency >> to 0, hence making it event based and doing what you want when the >> checkbox is clicked? >> >> like i said correct me if im wrong, but it seems pretty self-explanitory >> in the docs > > Oops, didn''t notice the statement that 0 will take a different approach. > Thanks - I''ll try that.no problem -- Posted via http://www.ruby-forum.com/.