Permalink
Browse files

[slider] Adding new behaviour to widget definition

  • Loading branch information...
1 parent ca3c393 commit 277832549b4486e5767df6665656b7ff191bb86c @gabrielschulhof gabrielschulhof committed Oct 23, 2012
Showing with 17 additions and 3 deletions.
  1. +17 −3 js/widgets/forms/slider.js
@@ -5,13 +5,11 @@
//>>css.structure: ../css/structure/jquery.mobile.forms.slider.css
//>>css.theme: ../css/themes/default/jquery.mobile.theme.css
-define( [ "jquery", "../../jquery.mobile.core", "../../jquery.mobile.widget", "./textinput", "../../jquery.mobile.buttonMarkup" ], function( $ ) {
+define( [ "jquery", "../../jquery.mobile.core", "../../jquery.mobile.widget", "./textinput", "../../jquery.mobile.buttonMarkup", "./reset" ], function( $ ) {
//>>excludeEnd("jqmBuildExclude");
(function( $, undefined ) {
$.widget( "mobile.slider", $.mobile.widget, {
- widgetEventPrefix: "slide",
-
options: {
theme: null,
trackTheme: null,
@@ -178,6 +176,10 @@ $.widget( "mobile.slider", $.mobile.widget, {
this.handle.bind( "vclick", false );
+ if ( this._handleFormReset ) {
+ this._handleFormReset();
+ }
+
this.refresh( undefined, undefined, true );
},
@@ -341,6 +343,11 @@ $.widget( "mobile.slider", $.mobile.widget, {
return this.isToggleSwitch ? this.element[0].selectedIndex : parseFloat( this.element.val() ) ;
},
+
+ _reset: function() {
+ this.refresh( undefined, false, true );
+ },
+
refresh: function( val, isfromControl, preventInputUpdate ) {
// NOTE: we don't return here because we want to support programmatic
@@ -468,6 +475,13 @@ $.widget( "mobile.slider", $.mobile.widget, {
});
+$.widget( "mobile.slider", $.mobile.slider, $.mobile.behaviors.formReset );
+
+// FIXME: Move the declaration of widgetEventPrefix back to the top of the
+// initial declaration of the slider widget once we start using a version of
+// the widget factory that includes a fix for http://bugs.jqueryui.com/ticket/8724
+$.widget( "mobile.slider", $.mobile.slider, { widgetEventPrefix: "slide" } );
+
//auto self-init widgets
$( document ).bind( "pagecreate create", function( e ) {
$.mobile.slider.prototype.enhanceWithin( e.target, true );

0 comments on commit 2778325

Please sign in to comment.