是否有任何捷径:
link_to 'title', path, 'data-type' => :html
我认为:type=>:html
会起作用,就像:remote=>true
转换为data-remote='true'
,但不受支持。
是否有任何捷径:
link_to 'title', path, 'data-type' => :html
我认为:type=>:html
会起作用,就像:remote=>true
转换为data-remote='true'
,但不受支持。
是的:
link_to 'title', path, data: { type: :html }
小编辑
它来自标签助手:http ://api.rubyonrails.org/classes/ActionView/Helpers/TagHelper.html#method-i-tag
在您的情况下,它可能不是捷径,但如果您必须设置多个数据属性,它会非常方便:
link_to 'title', path, data: { first_name: @user.first_name,
last_name: @user.last_name,
# etc. }
但是不,不type: :html
,对不起……