有没有质量的方式来更新“link_to_remote”里面的文字和离开链接的功能?基本上我有两个链接:

  <%= link_to_remote "(#{building.charts.size} Charts)",{:url => {:action => "update_chart_matrix", :chartable_type => "building",:chartable_id => building.id, :title => building.name},
    :update => 'chart-matrix',
}
%>

...和...

<%= link_to_remote "Add Chart",{:url => {:action => "add_chart_for_chartable", :chartable_type => "building",:chartable_id => building.id},
    :update => 'other_link', #really not sure about this part as I only want to update the Chart Count in the other link
}
%>

这将是很容易简单地更换链接内的HTML,但我不希望“破发”的功能。任何想法?

感谢。

有帮助吗?

解决方案

更新一个链接不会打破onclick功能的内部HTML。您正在使用的原型更新(通过滑轨),其设定的的innerHTML:

update: function(element, content) {
  element = $(element);
  if (content && content.toElement) content = content.toElement();
  if (Object.isElement(content)) return element.update().insert(content);
  content = Object.toHTML(content);
  // This sets innerHTML, it doesn't destroy the object
  element.innerHTML = content.stripScripts();
  content.evalScripts.bind(content).defer();
  return element;
},

只要回来的含量是合适的,以住的a标记内,你应该罚款。

祝你好运!

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top