开发者

In form_remote_tag how to replace paramaters Form.serialize(this) with Form.serialize('test_form)?

While using form_remote_tag(options = {}, &block)

form_remote_tag :html => { :action => url_for(:controller => "some", :action => "place") } 
Generates:
 <form action="/some/place" method="post" onsubmit="new Ajax.Request('',
{asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;">

I want to change for parameters in the "new Ajax.Request( ..." code like Form.serialize("test_form") so that the generated code is like

 <form action="/some/place" method="post" onsubmit="new Ajax.Request('',
{asynchronous:true, evalScripts:true, parameters:Form.开发者_StackOverflow中文版serialize(test_form)}); return false;">

Is there a way to pass any options to change that or is there a better way to handle this?


<% options = {:url => "/some/place", :with =>"Form.serialize('test_form')" }%>
<% form_remote_tag :html => { :onsubmit => #{remote_function(options)}; return false"} 

This would server the purpose as the options passed to html get appended to the remote function call and return false would ensure that it overirdes the default generated by rails.

The below would be the sample form generatd

 < form onsubmit="new Ajax.Request('/some/place', {asynchronous:true, evalScripts:true, parameters:Form.serialize('test_form') )}); return false; new Ajax.Request('',{asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜