Skip to content
This repository has been archived by the owner on Oct 8, 2021. It is now read-only.

Commit

Permalink
[formReset] New behaviour that allows form widgets to become aware of…
Browse files Browse the repository at this point in the history
… the fact that the form they are in has been reset
  • Loading branch information
Gabriel Schulhof committed Oct 23, 2012
1 parent 398ecd9 commit 0f212b3
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
3 changes: 2 additions & 1 deletion js/index.php
Expand Up @@ -19,7 +19,7 @@
'jquery.hashchange.js',
'widgets/page.js',
'jquery.mobile.core.js',
'widgets/loader.js',
'widgets/loader.js',
'jquery.mobile.navigation.js',
'jquery.mobile.navigation.pushstate.js',
'jquery.mobile.transition.js',
Expand All @@ -42,6 +42,7 @@
'widgets/listview.filter.js',
'widgets/listview.autodividers.js',
'jquery.mobile.nojs.js',
'widgets/forms/reset.js',
'widgets/forms/checkboxradio.js',
'widgets/forms/button.js',
'widgets/forms/slider.js',
Expand Down
3 changes: 3 additions & 0 deletions js/jquery.mobile.core.js
Expand Up @@ -120,6 +120,9 @@ define( [ "jquery", "text!../version.txt" ], function( $, __version__ ) {
WINDOWS: 91 // COMMAND
},

// Place to store various widget extensions
behaviors: {},

// Scroll page vertically: scroll to 0 to hide iOS address bar, or pass a Y value
silentScroll: function( ypos ) {
if ( $.type( ypos ) !== "number" ) {
Expand Down
23 changes: 23 additions & 0 deletions js/widgets/forms/reset.js
@@ -0,0 +1,23 @@
//>>excludeStart("jqmBuildExclude", pragmas.jqmBuildExclude);
//>>description: Make a widget react to a form's reset.
//>>label: formReset
//>>group: Forms

define( [ "jquery", "../../jquery.mobile.core" ], function( $ ) {
//>>excludeEnd("jqmBuildExclude");
(function( $, undefined ) {

$.mobile.behaviors.formReset = {
_handleFormReset: function() {
this._on( this.element.closest( "form" ), {
reset: function() {
this._delay( "_reset" );
}
});
}
};

})( jQuery );
//>>excludeStart("jqmBuildExclude", pragmas.jqmBuildExclude);
});
//>>excludeEnd("jqmBuildExclude");

0 comments on commit 0f212b3

Please sign in to comment.