开发者

RoR remote_function pass class name of element

开发者 https://www.devze.com 2023-01-13 22:16 出处:网络
In remote_function how can i pass the className of the form element i have the following code, <%=link_to(content_tag(\'span\',t(\'country.name\')),\'#\',

In remote_function how can i pass the className of the form element

i have the following code,

<%=link_to(content_tag('span',t('country.name')),'#',
   {:title=>t('country.name'),**:class=>"change_list"**,
    :onclick=>remote_function(:url => {:action => :change_view},
    :with =>"'**change**=**'+ ?????"**)}) %>

so, on onclick, i want to pass the parameter :change with the value o开发者_JAVA技巧f :class=>"change_list"

thanks,


If I am understanding correctly, that you want to pass the class name of the anchor tag in your Ajax request, then the following should work (re-formatted to try and improve readability):

<%= link_to(
      content_tag('span', t('country.name')), 
      '#',
      { :title   => t('country.name'),
        :class   => "change_list", 
        :onclick => remote_function(
        :url     => {:action => :change_view}, 
        :with    => "'change=' + this.className"
        )
      }) 
%>
0

精彩评论

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