Article Introduction: This article gives us a deep understanding of how components are automatically initialized in the internal design principles of jquery Mobile. |
In this article, let's take a deep look at the internal design principles of jquery Mobile. How components are initialized automatically
(Note: The code snippet in the following example is from version 1.1.0)
Many students who have seen the source code or have used jquery mobile students, we have a very big problem:
-------jquery Mobile provides several components, how do they automatically initialize?
!! Key Note: The following similar automatic initialization process is pagecreate triggered after the call, relevant instructions on Pagecreate can see the relevant introduction of my previous
We pick one of the components: ListView
First Look at a flowchart:
SOURCE Example:
#5193 bound inside the Pagecreate $ (document). Bind ("pagecreate create", function (e) { //call Enhancewithin, passed an argument: target ( Dom object)
1, $.mobile.listview.prototype.enhancewithin
#1203 enhancewith:function (target,usekeepnative) {// call This.enhance // Note here: Options.initselector will be read to filter the selection
2, enhance
1207 Enhance:function (targets,usekeepnative) { var $widgetElements = $ (targets); //...... $widgetElements = $.mobile.enhanceable ($widgetElements); Note: The widgetname:name //conversion to call plug-in //$ (selector)//this.widgetname:listview ===> loaded in #979 row [" ListView "] ();