Skip to content

Commit 1df2d3b

Browse files
JangoSteveNeeraj Singh
authored andcommitted
Fixed required field description and added better example docs for ajax:aborted events.
1 parent 324b2f2 commit 1df2d3b

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

src/rails.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
* The `ajax:aborted:file` event allows you to bind your own handler to process the form submission however you wish.
1414
*
1515
* Ex:
16-
* $('form').live('ajax:aborted:file', function(){
17-
* // Implement own remote file-transfer handler here.
16+
* $('form').live('ajax:aborted:file', function(event, elements){
17+
* // Implement own remote file-transfer handler here for non-blank file inputs passed in `elements`.
1818
* // Returning false in this handler tells rails.js to disallow standard form submission
1919
* return false;
2020
* });
@@ -27,17 +27,18 @@
2727
* Required fields in rails.js
2828
* ===========================
2929
*
30-
* If any required input field (input[required]) is blank then the AJAX form submission is cancelled.
31-
* Note that unlike file uploads case here the whole form submission is cancelled ,by default.
30+
* If any blank required inputs (required="required") are detected in the remote form, the whole form submission
31+
* is canceled. Note that this is unlike non-blank file inputs, which still allow non-AJAX form submission.
3232
*
3333
* The `ajax:aborted:required` event allows you to bind your own handler to inform the user of blank required inputs.
3434
*
35-
* !! Note that Opera does not fire the form's submit event if there are blank required inputs,
36-
* so this event may never get fired in Opera.
35+
* !! Note that Opera does not fire the form's submit event if there are blank required inputs, so this event may never
36+
* get fired in Opera. This event is what causes other browsers to exhibit the same submit-aborting behavior.
3737
*
3838
* Ex:
39-
* $('form').live('ajax:aborted:required', function(){
40-
* // Returning false in this handler tells rails.js to submit the form anyway
39+
* $('form').live('ajax:aborted:required', function(event, elements){
40+
* // Returning false in this handler tells rails.js to submit the form anyway.
41+
* // The blank required inputs are passed to this function in `elements`.
4142
* return ! confirm("Would you like to submit the form with missing info?");
4243
* });
4344
*/

0 commit comments

Comments
 (0)