Extract jquery mobile's function for clearable text box -


screenshot of need exactly. <br>

i have implemented mobile website. have used normal jquery v1.7.2 this. facing problem not able make clearable textbox supports , works in devices.

tried using clearabletextfield plugin.
working fine when take mobile site in desktop browser. when take mobil site in mobile device works if didnt change orientation of device. while tilting device position goes somewhere.
, if fix same in android not work in ios devices (sometimes working , not)

after all, started checking examples got. , 1 working http://api.jquerymobile.com/textinput/

is possible extract function alone ?

here code in jquery mobile js file.
http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.js

(function( $, undefined ) {      $.widget( "mobile.textinput", $.mobile.textinput, {         options: {             clearbtn: false,             clearbtntext: "clear text"         },          _create: function() {             this._super();              if ( !!this.options.clearbtn || this.issearch ) {                 this._addclearbtn();             }         },          clearbutton: function() {              return $( "<a href='#' class='ui-input-clear ui-btn ui-icon-delete ui-btn-icon-notext ui-corner-all" +     "' title='" + this.options.clearbtntext + "'>" + this.options.clearbtntext + "</a>" );          },          _clearbtnclick: function( event ) {             this.element.val( "" )                     .focus()                     .trigger( "change" );              this._clearbtn.addclass( "ui-input-clear-hidden" );             event.preventdefault();         },          _addclearbtn: function() {              if ( !this.options.enhanced ) {                 this._enhanceclear();             }              $.extend( this, {                 _clearbtn: this.widget().find("a.ui-input-clear")             });              this._bindclearevents();              this._toggleclear();          },          _enhanceclear: function() {              this.clearbutton().appendto( this.widget() );             this.widget().addclass( "ui-input-has-clear" );          },          _bindclearevents: function() {              this._on( this._clearbtn, {                 "click": "_clearbtnclick"             });              this._on({                 "keyup": "_toggleclear",                 "change": "_toggleclear",                 "input": "_toggleclear",                 "focus": "_toggleclear",                 "blur": "_toggleclear",                 "cut": "_toggleclear",                 "paste": "_toggleclear"              });          },          _unbindclear: function() {             this._off( this._clearbtn, "click");             this._off( this.element, "keyup change input focus blur cut paste" );         },          _setoptions: function( options ) {             this._super( options );              if ( options.clearbtn !== undefined &&                 !this.element.is( "textarea, :jqmdata(type='range')" ) ) {                 if ( options.clearbtn ) {                     this._addclearbtn();                 } else {                     this._destroyclear();                 }             }              if ( options.clearbtntext !== undefined && this._clearbtn !== undefined ) {                 this._clearbtn.text( options.clearbtntext )                     .attr("title", options.clearbtntext);             }         },          _toggleclear: function() {             this._delay( "_toggleclearclass", 0 );         },          _toggleclearclass: function() {             this._clearbtn.toggleclass( "ui-input-clear-hidden", !this.element.val() );         },          _destroyclear: function() {             this.widget().removeclass( "ui-input-has-clear" );             this._unbindclear();             this._clearbtn.remove();         },          _destroy: function() {             this._super();             this._destroyclear();         }      });  })( jquery ); 

why not use

<input type="search"> 

? in compliant browsers plain works. believe support pretty on mobile.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -