문제

"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을 간단히 교체하는 것은 쉽지만 기능을 "중단"하고 싶지는 않습니다. 어떤 아이디어?

감사.

도움이 되었습니까?

해결책

링크의 내부 HTML을 업데이트하면 onclick 기능. 프로토 타입 (레일을 통해)에서 업데이트를 사용하고 있는데, 이는 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