Skip to content

Commit c90885d

Browse files
committed
Merge pull request #412 from pothibo/master
Links with [disabled] attribute set will not trigger AJAX
2 parents c77ab38 + f042bf8 commit c90885d

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

Diff for: src/rails.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

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

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

Diff for: test/public/test/data-remote.js

+19
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ module('data-remote', {
1919
method: 'post',
2020
id: 'my-remote-form'
2121
}))
22+
.append($('<a />', {
23+
href: '/echo',
24+
'data-remote': 'true',
25+
disabled: 'disabled',
26+
text: 'Disabed link'
27+
}))
2228
.find('form').append($('<input type="text" name="user_name" value="john">'));
2329

2430
}
@@ -85,6 +91,19 @@ asyncTest('clicking on a link with data-remote attribute', 5, function() {
8591
.trigger('click');
8692
});
8793

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

0 commit comments

Comments
 (0)