2 * "button" plugin - links that proxy to native input/buttons
5 (function( $, undefined ) {
7 $.widget( "mobile.button", $.mobile.widget, {
16 initSelector: "button, [type='button'], [type='submit'], [type='reset'], [type='image']"
19 var $el = this.element,
26 this.button = $( "<div></div>" )
27 .text( $el.text() || $el.val() )
36 iconshadow: o.iconshadow
38 .append( $el.addClass( "ui-btn-hidden" ) );
40 type = $el.attr( "type" );
41 name = $el.attr( "name" );
43 // Add hidden input during submit if input type="submit" has a name.
44 if ( type !== "button" && type !== "reset" && name ) {
45 $el.bind( "vclick", function() {
46 // Add hidden input if it doesn’t already exist.
47 if( $buttonPlaceholder === undefined ) {
48 $buttonPlaceholder = $( "<input>", {
50 name: $el.attr( "name" ),
51 value: $el.attr( "value" )
52 }).insertBefore( $el );
54 // Bind to doc to remove after submit handling
55 $( document ).one("submit", function(){
56 $buttonPlaceholder.remove();
58 // reset the local var so that the hidden input
59 // will be re-added on subsequent clicks
60 $buttonPlaceholder = undefined;
70 this.element.attr( "disabled", false );
71 this.button.removeClass( "ui-disabled" ).attr( "aria-disabled", false );
72 return this._setOption( "disabled", false );
76 this.element.attr( "disabled", true );
77 this.button.addClass( "ui-disabled" ).attr( "aria-disabled", true );
78 return this._setOption( "disabled", true );
82 var $el = this.element;
84 if ( $el.prop("disabled") ) {
90 // the textWrapper is stored as a data element on the button object
91 // to prevent referencing by it's implementation details (eg 'class')
92 this.button.data( 'textWrapper' ).text( $el.text() || $el.val() );
96 //auto self-init widgets
97 $( document ).bind( "pagecreate create", function( e ){
98 $.mobile.button.prototype.enhanceWithin( e.target );