Article Introduction: This article gives us a deep understanding of the very, very useful events of the jquery mobile system. |
This article gives us a deep understanding of the very, very useful events of the jquery Mobile system:
--------Pagecreate and the origin of Pagebeforecreate!
(Note: The code snippet in the following example is from version 1.1.0)
Many people who have read the source code, should be in many places to see the following kind of event binding, I picked the first place to appear:
Source code Example:
#4010 $ (document). Bind ("pagecreate create", function (e) {
A long time ago, I have a question?
------What I see seems to be bind a pagecreate custom event, where trigger?
So I all kinds of search pagecreate, the result ... Wood there! Yes, it's wood!!
The problem is big, there is no trigger this pagecreate setting, that write 200000 ... A bind is no use!
-----------------------------the gorgeous divider line--------------------------------------
Let me show you the following:
First Look at a flowchart:
1. Starting point: _createwidget
#1179 _createwidget:function () { //call $. Widget.prototype._createwidget $. Widget.prototype._createwidget.apply (this,arguments);
2, $. Widget.prototype._createwidget
$. Widget.prototype = { //1047 _createwidget:function (options,element) { //.... Omit part this._create (); This._trigger ("create");
3, _create
2132 _create:function () { var self = this; if (Self._trigger ("beforecreate") = = False) {return false; }
4, $. Widget.prototype._trigger
Key points, attention to detail description:
_trigger:function (type,event,data) { var callback = This.options[type]; Event = $. Event (event); Strong note here: //this.widgeteventprefix ====> page //980 $[namespace][name].prototype.widgeteventprefix name //type after processing: //page+beforecreate ==> pagebeforecreate //page+create ==> Event.type = (Type = = This.widgeteventprefix? type:this.widgetEventPrefix + type). toLowerCase (); data = Data {}; //...
Description
1, in fact, the core or $. Widget.prototype._trigger, the inside will handle the type