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

Commit 0f212b3

Browse files
author
Gabriel Schulhof
committed
[formReset] New behaviour that allows form widgets to become aware of the fact that the form they are in has been reset
1 parent 398ecd9 commit 0f212b3

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

js/index.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
'jquery.hashchange.js',
2020
'widgets/page.js',
2121
'jquery.mobile.core.js',
22-
'widgets/loader.js',
22+
'widgets/loader.js',
2323
'jquery.mobile.navigation.js',
2424
'jquery.mobile.navigation.pushstate.js',
2525
'jquery.mobile.transition.js',
@@ -42,6 +42,7 @@
4242
'widgets/listview.filter.js',
4343
'widgets/listview.autodividers.js',
4444
'jquery.mobile.nojs.js',
45+
'widgets/forms/reset.js',
4546
'widgets/forms/checkboxradio.js',
4647
'widgets/forms/button.js',
4748
'widgets/forms/slider.js',

js/jquery.mobile.core.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@ define( [ "jquery", "text!../version.txt" ], function( $, __version__ ) {
120120
WINDOWS: 91 // COMMAND
121121
},
122122

123+
// Place to store various widget extensions
124+
behaviors: {},
125+
123126
// Scroll page vertically: scroll to 0 to hide iOS address bar, or pass a Y value
124127
silentScroll: function( ypos ) {
125128
if ( $.type( ypos ) !== "number" ) {

js/widgets/forms/reset.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//>>excludeStart("jqmBuildExclude", pragmas.jqmBuildExclude);
2+
//>>description: Make a widget react to a form's reset.
3+
//>>label: formReset
4+
//>>group: Forms
5+
6+
define( [ "jquery", "../../jquery.mobile.core" ], function( $ ) {
7+
//>>excludeEnd("jqmBuildExclude");
8+
(function( $, undefined ) {
9+
10+
$.mobile.behaviors.formReset = {
11+
_handleFormReset: function() {
12+
this._on( this.element.closest( "form" ), {
13+
reset: function() {
14+
this._delay( "_reset" );
15+
}
16+
});
17+
}
18+
};
19+
20+
})( jQuery );
21+
//>>excludeStart("jqmBuildExclude", pragmas.jqmBuildExclude);
22+
});
23+
//>>excludeEnd("jqmBuildExclude");

0 commit comments

Comments
 (0)