javascript - (Rails) How do you replace the text of a "link_to_remote" without breaking the link? -
Is there a quality way to update the text inside a "link_to_remote" and leave the link functional? Basically I have two links:
& lt;% = link_to_remote "(# {building.charts.size} chart)", {: url = & gt; {: Action = & gt; "Update_chart_matrix",: chartable_type = & gt; "Building",: chartable_id = & gt; Building.id ,: title = & gt; Building.name} ,: update = & gt; 'Chart-matrix',}%>
... and ...
& lt;% = link_to_remote "Add chart", {: url = & gt; {: Action = & gt; "Add_chart_for_chartable" ,: chartable_type = & gt; "Building",: chartable_id = & gt; Building.id} ,: update = & gt; 'Other_link', is definitely not sure about this part because I only want to update the chart count in the second link}% & gt;
This link will be easy to replace HTML only, but I do not want to "break" its functionality. Any ideas?
Thank you.
Updating the internal HTML of a link won 't to the onclick
functionality To break You are using the update in prototype (via rail), which sets the internal HTML:
update: function (element, content) {element = $ (element); If (content and content. Element) content = content. Element (); If (Object.isElement (content) return element.update (). Insert (content); Content = object.toHTML (content); // It sets the internal HTML, it does not delete the object element. WinnerHTML = content.stripScripts (); Content.evalScripts.bind (content) .defer (); Return element; },
Unless the content is suitable for staying inside an a
tag, then you should be OK.
Good luck!
Comments
Post a Comment