-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtestwidget.js
More file actions
35 lines (28 loc) · 818 Bytes
/
testwidget.js
File metadata and controls
35 lines (28 loc) · 818 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
( function( $, undefined ) {
$.widget( "mobile.testwidget", $.mobile.widget, {
options: {
repository: null,
initSelector: ":jqmData(role='testwidget')"
},
_create: function() {
this.element.text( "This is a test widget" );
},
_setOptions: function( options ) {
var promise = options.repository;
if ( promise != null ) {
if ( $.type( promise ) === "string" ) {
promise = $.ajax({ url: options.repository });
}
promise.always( $.proxy( this, "_requestDone" ) );
}
},
_requestDone: function( data, textStatus, jqHXR ) {
console.log( "request done with status " + textStatus + " and data:" );
console.log( data );
this._trigger( "done" );
}
});
$( document ).bind( "pagecreate", function( e ) {
$.mobile.testwidget.prototype.enhanceWithin( $( e.target ) );
});
})( jQuery );