Skip to content
This repository has been archived by the owner on Oct 8, 2021. It is now read-only.

Commit

Permalink
Clarified the documentation around the purpose of the pagebeforecreat…
Browse files Browse the repository at this point in the history
…e 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.
  • Loading branch information
scottjehl committed Aug 27, 2011
1 parent 10e2d5a commit 6de7616
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
7 changes: 3 additions & 4 deletions docs/api/events.html
Expand Up @@ -106,18 +106,17 @@ <h2>Page initialization events</h2>
<dl>
<dt><code>pagebeforecreate</code></dt>
<dd>
<p>Triggered on the page being initialized, before initialization occurs.</p>
<p>Triggered on the page being initialized, before most plugin auto-initialization occurs.</p>
<pre><code>
$('#aboutPage').live('pagebeforecreate',function(event){
alert('This page was just inserted into the dom!');
});
</code></pre>
<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>
<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>

<pre><code>
$('#aboutPage').live('pagebeforecreate',function(event){
//run your own enhancement scripting here...
return false;
// manipulate this page before its widgets are auto-initialized
});
</code></pre>
</dd>
Expand Down
8 changes: 3 additions & 5 deletions js/jquery.mobile.page.js
Expand Up @@ -15,11 +15,9 @@ $.widget( "mobile.page", $.mobile.widget, {

_create: function() {

if ( this._trigger( "beforeCreate" ) === false ) {
return;
}

this.element.addClass( "ui-page ui-body-" + this.options.theme );
this._trigger( "beforecreate" );

this.element.addClass( "ui-page ui-body-" + this.options.theme );
}
});

Expand Down

0 comments on commit 6de7616

Please sign in to comment.