Skip to content

Commit f1bdd1f

Browse files
committed
Upgraded to latest jquery-ujs.
1 parent 56c4445 commit f1bdd1f

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

lib/jquery/rails/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ module Rails
33
VERSION = "1.0.14"
44
JQUERY_VERSION = "1.6.2"
55
JQUERY_UI_VERSION = "1.8.14"
6-
JQUERY_UJS_VERSION = "c00a9726837756ea53404ca7e8b0f12df19a6496"
6+
JQUERY_UJS_VERSION = "acd1a149fb715710c22e56ee4c50a9c6ab840709"
77
end
88
end

vendor/assets/javascripts/jquery_ujs.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
formSubmitSelector: 'form',
5959

6060
// Form input elements bound by jquery-ujs
61-
formInputClickSelector: 'form input[type=submit], form input[type=image], form button[type=submit], form button:not([type])',
61+
formInputClickSelector: 'form input[type=submit], form input[type=image], form button[type=submit], form button:not(button[type])',
6262

6363
// Form input elements disabled during form submission
6464
disableSelector: 'input[data-disable-with], button[data-disable-with], textarea[data-disable-with]',
@@ -159,6 +159,7 @@
159159
handleMethod: function(link) {
160160
var href = link.attr('href'),
161161
method = link.data('method'),
162+
target = link.attr('target'),
162163
csrf_token = $('meta[name=csrf-token]').attr('content'),
163164
csrf_param = $('meta[name=csrf-param]').attr('content'),
164165
form = $('<form method="post" action="' + href + '"></form>'),
@@ -168,33 +169,35 @@
168169
metadata_input += '<input name="' + csrf_param + '" value="' + csrf_token + '" type="hidden" />';
169170
}
170171

172+
if (target) { form.attr('target', target); }
173+
171174
form.hide().append(metadata_input).appendTo('body');
172175
form.submit();
173176
},
174177

175178
/* Disables form elements:
176179
- Caches element value in 'ujs:enable-with' data store
177180
- Replaces element text with value of 'data-disable-with' attribute
178-
- Adds disabled=disabled attribute
181+
- Sets disabled property to true
179182
*/
180183
disableFormElements: function(form) {
181184
form.find(rails.disableSelector).each(function() {
182185
var element = $(this), method = element.is('button') ? 'html' : 'val';
183186
element.data('ujs:enable-with', element[method]());
184187
element[method](element.data('disable-with'));
185-
element.attr('disabled', 'disabled');
188+
element.prop('disabled', true);
186189
});
187190
},
188191

189192
/* Re-enables disabled form elements:
190193
- Replaces element text with cached value from 'ujs:enable-with' data store (created in `disableFormElements`)
191-
- Removes disabled attribute
194+
- Sets disabled property to false
192195
*/
193196
enableFormElements: function(form) {
194197
form.find(rails.enableSelector).each(function() {
195198
var element = $(this), method = element.is('button') ? 'html' : 'val';
196199
if (element.data('ujs:enable-with')) element[method](element.data('ujs:enable-with'));
197-
element.removeAttr('disabled');
200+
element.prop('disabled', false);
198201
});
199202
},
200203

@@ -288,12 +291,13 @@
288291
});
289292

290293
$(rails.linkClickSelector).live('click.rails', function(e) {
291-
var link = $(this);
294+
var link = $(this), method = link.data('method'), data = link.data('params');
292295
if (!rails.allowAction(link)) return rails.stopEverything(e);
293296

294297
if (link.is(rails.linkDisableSelector)) rails.disableElement(link);
295298

296299
if (link.data('remote') !== undefined) {
300+
if ( (e.metaKey || e.ctrlKey) && (!method || method === 'GET') && !data ) { return true; }
297301
rails.handleRemote(link);
298302
return false;
299303
} else if (link.data('method')) {

0 commit comments

Comments
 (0)