1 $.rails.href = function(element) {
3 // data-remote=true links must put their remote targets in
4 // data-remote-href="..." instead of href="...". This helps
5 // us avoid accidentally using the same href="..." in both the
6 // remote (Rails UJS) and non-remote (native browser) handlers
7 // -- which differ greatly in how they use that value -- and
8 // forgetting to test any non-remote cases like "open in new
9 // tab". If you really want copy-link-address/open-in-new-tab
10 // to work on a data-remote=true link, supply the
11 // copy-and-pastable URI in href in addition to the AJAX URI
12 // in data-remote-href.
14 // (Currently, the only places we make any remote links are
15 // link_to() in ApplicationHelper, which renames href="..." to
16 // data-remote-href="...", and select_modal, which builds a
17 // data-remote=true link on the client side.)
18 return element.data('remote-href');
20 // Normal rails-ujs behavior.
21 return element.attr('href');