|
112 | 112 | } else { |
113 | 113 | method = element.data('method'); |
114 | 114 | url = element.attr('href'); |
115 | | - data = null; |
116 | | - } |
| 115 | + data = element.data('params') || null; |
| 116 | + } |
117 | 117 |
|
118 | 118 | rails.ajax({ |
119 | 119 | url: url, type: method || 'GET', data: data, dataType: dataType, |
|
181 | 181 | }); |
182 | 182 | }, |
183 | 183 |
|
184 | | - /* If message provided in 'data-confirm' attribute: |
185 | | - - fires `confirm` event |
186 | | - - shows the confirm dialog |
187 | | - - fires the `confirmed` event |
188 | | - and returns true if no function stopped the chain and user chose yes; false otherwise. |
189 | | - Attaching a handler to the element's `confirm` event that returns false cancels the confirm dialog. |
190 | | - */ |
| 184 | + /* For 'data-confirm' attribute: |
| 185 | + - Fires `confirm` event |
| 186 | + - Shows the confirmation dialog |
| 187 | + - Fires the `confirm:complete` event |
| 188 | +
|
| 189 | + Returns `true` if no function stops the chain and user chose yes; `false` otherwise. |
| 190 | + Attaching a handler to the element's `confirm` event that returns a `falsy` value cancels the confirmation dialog. |
| 191 | + Attaching a handler to the element's `confirm:complete` event that returns a `falsy` value makes this function |
| 192 | + return false. The `confirm:complete` event is fired whether or not the user answered true or false to the dialog. |
| 193 | + */ |
191 | 194 | allowAction: function(element) { |
192 | 195 | var message = element.data('confirm'), |
193 | 196 | answer = false, callback; |
|
221 | 224 |
|
222 | 225 | // Helper function, needed to provide consistent behavior in IE |
223 | 226 | stopEverything: function(e) { |
| 227 | + $(e.target).trigger('ujs:everythingStopped'); |
224 | 228 | e.stopImmediatePropagation(); |
225 | 229 | return false; |
226 | 230 | }, |
|
268 | 272 |
|
269 | 273 | // skip other logic when required values are missing or file upload is present |
270 | 274 | if (blankRequiredInputs && rails.fire(form, 'ajax:aborted:required', [blankRequiredInputs])) { |
271 | | - return !remote; |
| 275 | + return rails.stopEverything(e); |
272 | 276 | } |
273 | 277 |
|
274 | 278 | if (remote) { |
|
0 commit comments