[英]link_to_remote attributes/arguments in rails 3
我正在尝试从Rails 2.3升级到3.0,我发现Rails 2中的link_to_remote
应该使用:remote => true
属性更改为rails 3中的link_to
。
和不干扰人的javascript(UJS) :before, :loading, :failure, :update
但是我也有像:url, :href, :title
这样的属性:url, :href, :title
我应该如何改变呢?
这是我正在尝试升级的Rails 2.3代码
<%= link_to_remote column.label,
{ :url => sort_params,
:before => "addActiveScaffoldPageToHistory('#{href}', '#{controller_id}')",
:loading => "Element.addClassName('#{column_header_id}','loading');",
:failure => "ActiveScaffold.report_500_response('#{active_scaffold_id}')",
:update => active_scaffold_content_id,
:method => :get },
{ :href => href ,
:title => column.header_info}%>
我已经分析了许多网站和Rails文档,但没有为link_to
这些属性指定任何内容
您可以在Rails 3中将回调绑定到远程链接,其余属性可以分配为选项。
link_to column.label,
sort_params,
remote: true,
title: column_header.info,
id: 'my_remote_link',
data: {
href: href,
controller_id: controller_id,
column_header_id: column_header_id,
active_scaffold_id: active_scaffold_id
}
我们将使用数据属性进行回调。
$('#my_remote_link').bind('ajax:beforeSend, function() {
addActiveScaffoldPageToHistory($('#my_remote_link').data('href'), $('#my_remote_link').data('controller_id'));
});
有关不同ajaxEvent的描述,请参见http://docs.jquery.com/Ajax_Events 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.