2 * widget factory extentions for mobile
5 (function( $, undefined ) {
7 $.widget( "mobile.widget", {
8 // decorate the parent _createWidget to trigger `widgetinit` for users
9 // who wish to do post post `widgetcreate` alterations/additions
11 // TODO create a pull request for jquery ui to trigger this event
12 // in the original _createWidget
13 _createWidget: function() {
14 $.Widget.prototype._createWidget.apply( this, arguments );
15 this._trigger( 'init' );
18 _getCreateOptions: function() {
20 var elem = this.element,
23 $.each( this.options, function( option ) {
25 var value = elem.jqmData( option.replace( /[A-Z]/g, function( c ) {
26 return "-" + c.toLowerCase();
30 if ( value !== undefined ) {
31 options[ option ] = value;
38 enhanceWithin: function( target ) {
39 // TODO remove dependency on the page widget for the keepNative.
40 // Currently the keepNative value is defined on the page prototype so
41 // the method is as well
42 var page = $(target).closest(":jqmData(role='page')").data( "page" ),
43 keepNative = (page && page.keepNativeSelector()) || "";
45 $( this.options.initSelector, target ).not( keepNative )[ this.widgetName ]();