jquery-rails 1.0.11 → 1.0.12

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of jquery-rails might be problematic. Click here for more details.

@@ -1,3 +1,8 @@
1
+ ## 1.0.12 (23 June 2011)
2
+
3
+ - Updated to latest jqueyr-ujs with 'blank form action' and
4
+ data-remote support for select elements
5
+
1
6
  ## 1.0.11 (15 June 2011)
2
7
 
3
8
  - Updated to latest jqueyr-ujs with cross-domain support
@@ -1,8 +1,8 @@
1
1
  module Jquery
2
2
  module Rails
3
- VERSION = "1.0.11"
3
+ VERSION = "1.0.12"
4
4
  JQUERY_VERSION = "1.6.1"
5
5
  JQUERY_UI_VERSION = "1.8.12"
6
- JQUERY_UJS_VERSION = "616e4fe354ce0ae5137636f9b5475782a7c9e896"
6
+ JQUERY_UJS_VERSION = "0e742688c633bda274f8a09bf3248ffe33ecaf92"
7
7
  end
8
8
  end
@@ -51,6 +51,9 @@
51
51
  // Link elements bound by jquery-ujs
52
52
  linkClickSelector: 'a[data-confirm], a[data-method], a[data-remote]',
53
53
 
54
+ // Select elements bound by jquery-ujs
55
+ selectChangeSelector: 'select[data-remote]',
56
+
54
57
  // Form elements bound by jquery-ujs
55
58
  formSubmitSelector: 'form',
56
59
 
@@ -110,14 +113,19 @@
110
113
  data.push(button);
111
114
  element.data('ujs:submit-button', null);
112
115
  }
113
- } else {
116
+ } else if (element.is('select')) {
114
117
  method = element.data('method');
115
- url = element.attr('href');
116
- data = element.data('params') || null;
117
- }
118
+ url = element.data('url');
119
+ data = element.serialize();
120
+ if (element.data('params')) data = data + "&" + element.data('params');
121
+ } else {
122
+ method = element.data('method');
123
+ url = element.attr('href');
124
+ data = element.data('params') || null;
125
+ }
118
126
 
119
- rails.ajax({
120
- url: url, type: method || 'GET', data: data, dataType: dataType, crossDomain: crossDomain,
127
+ options = {
128
+ type: method || 'GET', data: data, dataType: dataType, crossDomain: crossDomain,
121
129
  // stopping the "ajax:beforeSend" event will cancel the ajax request
122
130
  beforeSend: function(xhr, settings) {
123
131
  if (settings.dataType === undefined) {
@@ -134,7 +142,11 @@
134
142
  error: function(xhr, status, error) {
135
143
  element.trigger('ajax:error', [xhr, status, error]);
136
144
  }
137
- });
145
+ };
146
+ // Do not pass url to `ajax` options if blank
147
+ if (url) { $.extend(options, { url: url }); }
148
+
149
+ rails.ajax(options);
138
150
  }
139
151
  },
140
152
 
@@ -263,6 +275,14 @@
263
275
  }
264
276
  });
265
277
 
278
+ $(rails.selectChangeSelector).live('change.rails', function(e) {
279
+ var link = $(this);
280
+ if (!rails.allowAction(link)) return rails.stopEverything(e);
281
+
282
+ rails.handleRemote(link);
283
+ return false;
284
+ });
285
+
266
286
  $(rails.formSubmitSelector).live('submit.rails', function(e) {
267
287
  var form = $(this),
268
288
  remote = form.data('remote') !== undefined,
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: jquery-rails
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.0.11
5
+ version: 1.0.12
6
6
  platform: ruby
7
7
  authors:
8
8
  - "Andr\xC3\xA9 Arko"
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-06-15 00:00:00 Z
13
+ date: 2011-06-23 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: railties