Skip to content

Commit

Permalink
Fixed required field description and added better example docs for aj…
Browse files Browse the repository at this point in the history
…ax:aborted events.
  • Loading branch information
JangoSteve authored and Neeraj Singh committed Apr 20, 2011
1 parent 324b2f2 commit 1df2d3b
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/rails.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
* The `ajax:aborted:file` event allows you to bind your own handler to process the form submission however you wish.
*
* Ex:
* $('form').live('ajax:aborted:file', function(){
* // Implement own remote file-transfer handler here.
* $('form').live('ajax:aborted:file', function(event, elements){
* // Implement own remote file-transfer handler here for non-blank file inputs passed in `elements`.
* // Returning false in this handler tells rails.js to disallow standard form submission
* return false;
* });
Expand All @@ -27,17 +27,18 @@
* Required fields in rails.js
* ===========================
*
* If any required input field (input[required]) is blank then the AJAX form submission is cancelled.
* Note that unlike file uploads case here the whole form submission is cancelled ,by default.
* If any blank required inputs (required="required") are detected in the remote form, the whole form submission
* is canceled. Note that this is unlike non-blank file inputs, which still allow non-AJAX form submission.
*
* The `ajax:aborted:required` event allows you to bind your own handler to inform the user of blank required inputs.
*
* !! Note that Opera does not fire the form's submit event if there are blank required inputs,
* so this event may never get fired in Opera.
* !! Note that Opera does not fire the form's submit event if there are blank required inputs, so this event may never
* get fired in Opera. This event is what causes other browsers to exhibit the same submit-aborting behavior.
*
* Ex:
* $('form').live('ajax:aborted:required', function(){
* // Returning false in this handler tells rails.js to submit the form anyway
* $('form').live('ajax:aborted:required', function(event, elements){
* // Returning false in this handler tells rails.js to submit the form anyway.
* // The blank required inputs are passed to this function in `elements`.
* return ! confirm("Would you like to submit the form with missing info?");
* });
*/
Expand Down

0 comments on commit 1df2d3b

Please sign in to comment.