[英]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.