Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Method links with [disabled] attribute set will not trigger AJAX #502

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
2 changes: 1 addition & 1 deletion src/rails.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

$.rails = rails = {
// Link elements bound by jquery-ujs
linkClickSelector: 'a[data-confirm], a[data-method], a[data-remote]:not([disabled]), a[data-disable-with], a[data-disable]',
linkClickSelector: 'a[data-confirm], a[data-method]:not([disabled]), a[data-remote]:not([disabled]), a[data-disable-with], a[data-disable]',

// Button elements bound by jquery-ujs
buttonClickSelector: 'button[data-remote]:not([form]):not(form button), button[data-confirm]:not([form]):not(form button)',
Expand Down
26 changes: 23 additions & 3 deletions test/public/test/data-method.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,16 @@

module('data-method', {
setup: function() {
$('#qunit-fixture').append($('<a />', {
href: '/echo', 'data-method': 'delete', text: 'destroy!'
}));
$('#qunit-fixture')
.append($('<a />', {
href: '/echo', 'data-method': 'delete', text: 'destroy!'
}))
.append($('<a />', {
href: '/echo',
'data-method': 'post',
'disabled': 'disabled',
text: 'Disabled link'
}));
},
teardown: function() {
$(document).off('iframe:loaded');
Expand Down Expand Up @@ -72,4 +79,17 @@ asyncTest('link with "data-method" and cross origin', 1, function() {
notEqual(data.authenticity_token, 'cf50faa3fe97702ca1ae');
});

asyncTest('clicking on a link with disabled attribute', 0, function() {
$('a[disabled]')
.on("ajax:before", function(e, data, status, xhr) {
App.assertCallbackNotInvoked('ajax:success')
})
.on('ajax:complete', function() { start() })
.trigger('click')

setTimeout(function() {
start();
}, 13);
});

})();
2 changes: 1 addition & 1 deletion test/public/test/data-remote.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module('data-remote', {
href: '/echo',
'data-remote': 'true',
disabled: 'disabled',
text: 'Disabed link'
text: 'Disabled link'
}))
.find('form').append($('<input type="text" name="user_name" value="john">'));

Expand Down