Giles Bowkett
2006-Jul-27 05:32 UTC
[Rails] form_tag vs form_remote_tag ----- the :condition option
form_remote_tag has a really useful little thingamob called :condition. you give it a string which is then interpolated into the form tag in such a way that the form is only submitted if :condition evaluates in javascript to true. so the logical thing to do is give it a JavaScript function <%= form_remote_tag ( :condition => ''your_function_here()'', :url => {:action => ''your_action_here''} ) %> as you can see, it is nifty. but here''s the thing. form_tag **doesn''t** support this same useful feature as far as I can tell. am I wrong? is there a simple way to implement this feature? my JavaScript''s a bit rusty but I think you can probably just put it in a function, and then reference the function from the form tag in the HTML. if there''s anybody out there with fluent JavaScript -- does that sound right? -- Giles Bowkett http://www.gilesgoatboy.org
Giles Bowkett
2006-Jul-27 06:17 UTC
[Rails] Re: form_tag vs form_remote_tag ----- the :condition option
duh please ignore this question I forgot how easy this stuff was On 7/26/06, Giles Bowkett <gilesb@gmail.com> wrote:> form_remote_tag has a really useful little thingamob called > :condition. you give it a string which is then interpolated into the > form tag in such a way that the form is only submitted if :condition > evaluates in javascript to true. > > so the logical thing to do is give it a JavaScript function > > <%= form_remote_tag ( :condition => ''your_function_here()'', > :url => {:action => ''your_action_here''} ) %> > > as you can see, it is nifty. > > but here''s the thing. form_tag **doesn''t** support this same useful > feature as far as I can tell. > > am I wrong? > > is there a simple way to implement this feature? > > my JavaScript''s a bit rusty but I think you can probably just put it > in a function, and then reference the function from the form tag in > the HTML. if there''s anybody out there with fluent JavaScript -- does > that sound right? > > > -- > Giles Bowkett > http://www.gilesgoatboy.org >-- Giles Bowkett http://www.gilesgoatboy.org