Skip to content

Commit f042bf8

Browse files
committed
Links with [disabled] attribute set will not trigger AJAX
1 parent 75f7094 commit f042bf8

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/rails.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

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

2727
// Button elements bound by jquery-ujs
2828
buttonClickSelector: 'button[data-remote]:not(form button), button[data-confirm]:not(form button)',

test/public/test/data-remote.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ module('data-remote', {
1818
'data-remote': 'true',
1919
method: 'post'
2020
}))
21+
.append($('<a />', {
22+
href: '/echo',
23+
'data-remote': 'true',
24+
disabled: 'disabled',
25+
text: 'Disabed link'
26+
}))
2127
.find('form').append($('<input type="text" name="user_name" value="john">'));
2228

2329
}
@@ -84,6 +90,19 @@ asyncTest('clicking on a link with data-remote attribute', 5, function() {
8490
.trigger('click');
8591
});
8692

93+
asyncTest('clicking on a link with disabled attribute', 0, function() {
94+
$('a[disabled]')
95+
.bind("ajax:before", function(e, data, status, xhr) {
96+
App.assertCallbackNotInvoked('ajax:success')
97+
})
98+
.bind('ajax:complete', function() { start() })
99+
.trigger('click')
100+
101+
setTimeout(function() {
102+
start();
103+
}, 13);
104+
});
105+
87106
asyncTest('clicking on a button with data-remote attribute', 5, function() {
88107
$('button[data-remote]')
89108
.bind('ajax:success', function(e, data, status, xhr) {

0 commit comments

Comments
 (0)