Skip to content

Commit 6de7616

Browse files
author
scottjehl
committed
Clarified the documentation around the purpose of the pagebeforecreate event and removed the pagebeforecreate return value check, as returning beforecreate false is no longer relevant now that all plugins auto-init externally, rather than inline in the page plugin.
1 parent 10e2d5a commit 6de7616

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

docs/api/events.html

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,18 +106,17 @@ <h2>Page initialization events</h2>
106106
<dl>
107107
<dt><code>pagebeforecreate</code></dt>
108108
<dd>
109-
<p>Triggered on the page being initialized, before initialization occurs.</p>
109+
<p>Triggered on the page being initialized, before most plugin auto-initialization occurs.</p>
110110
<pre><code>
111111
$('#aboutPage').live('pagebeforecreate',function(event){
112112
alert('This page was just inserted into the dom!');
113113
});
114114
</code></pre>
115-
<p>Note that by binding to <code>pagebeforecreate</code> and returning <code>false</code>, you can prevent the page plugin from making its manipulations.</p>
115+
<p>Note that by binding to <code>pagebeforecreate</code>, you can manipulate markup before jQuery Mobile's default widgets are auto-initialized. For example, say you want to add data-attributes via JavaScript instead of in the HTML source, this is the event you'd use.</p>
116116

117117
<pre><code>
118118
$('#aboutPage').live('pagebeforecreate',function(event){
119-
//run your own enhancement scripting here...
120-
return false;
119+
// manipulate this page before its widgets are auto-initialized
121120
});
122121
</code></pre>
123122
</dd>

js/jquery.mobile.page.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,9 @@ $.widget( "mobile.page", $.mobile.widget, {
1515

1616
_create: function() {
1717

18-
if ( this._trigger( "beforeCreate" ) === false ) {
19-
return;
20-
}
21-
22-
this.element.addClass( "ui-page ui-body-" + this.options.theme );
18+
this._trigger( "beforecreate" );
19+
20+
this.element.addClass( "ui-page ui-body-" + this.options.theme );
2321
}
2422
});
2523

0 commit comments

Comments
 (0)