JQuery Mobile Tutorial: pagecreate Events

Source: Internet
Author: User
Tags bind

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



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.