Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/rails.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,19 @@
form.submit();
},

// Follow the href after a delay. To be used instead of the default handler to give the DOM a chance to render any changes
followLink: function(link) {
var href = rails.href(link),
target = $.trim(link.attr("target"));
setTimeout(function() {
if (target) {
open(href, target);
} else {
location = href;
}
}, 0);
},

/* Disables form elements:
- Caches element value in 'ujs:enable-with' data store
- Replaces element text with value of 'data-disable-with' attribute
Expand Down Expand Up @@ -316,6 +329,9 @@
} else if (link.data('method')) {
rails.handleMethod(link);
return false;
} else {
rails.followLink(link);
return false;
}
});

Expand Down
2 changes: 1 addition & 1 deletion test/public/test/call-remote.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ asyncTest('allow empty form "action"', 1, function() {
currentLocation.href = "";
currentLocation = currentLocation.href;
}
currentLocation = currentLocation.replace(/\?$/, '');
currentLocation = currentLocation.replace(/\??#?$/, '');

// Actual location (strip out settings.data that jQuery serializes and appends)
// HACK: can no longer use settings.data below to see what was appended to URL, as of
Expand Down
2 changes: 1 addition & 1 deletion test/public/test/data-disable.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module('data-disable', {

$('#qunit-fixture').append($('<a />', {
text: 'Click me',
href: '/echo',
href: '#',
'data-disable-with': 'clicking...'
}));
},
Expand Down