Rails 3 - Status of “link_to_function” method

后端 未结 3 1118
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-01 18:57

In searching for a solution to a javascript problem, I saw multiple comments about link_to_function being deprecated in Rails 3. However, I\'ve been able to co

3条回答
  •  长发绾君心
    2021-01-01 19:16

    While I am intending to switch everything over to unobtrusive javascript, a good intermediate step (for me), was to replace

    link_to_function icon_tag('close.png'), '$(this).parent().hide()', :title => t('actions.close'), :class => 'close'
    

    with the following:

    link_to icon_tag('close.png'), '#', :onclick => '$(this).parent().hide()', :title => t('actions.close'), :class => 'close'
    

    Very simple. Hope this helps.

提交回复
热议问题