With Easyui for a long time, but seldom to see the source. There is no solution to the problem of Baidu ...
Today found that the source of Easyui is not difficult to understand. And the combination of Easyloader can be very convenient to study the components of Easyui.
However, Easyloader's official API presentation is very brief.
Easyloader.base = '. /‘; Set Easyui base directory easyloader.load (' Messager ', function () {//Load specified module
Above
(1) Easyloader.base, which directory should be pointed to?
(2) easyloader.load (' Messager ', ... Don't need to introduce CSS files in advance?
These issues are not described in the API. No way, only to see the source.
After reading the source code, you can know:
(1) Easyloader.base, should point to a root directory, this root directory must be contains plugins, themes, locale, is actually downloaded from the official website Easyui a version of the root directory after the decompression. (explicitly set in the source code, loading CSS from the themes directory to get, loading JS from the plugins directory to get ...)
(2) easyloader.load (' Messager ', function () {}); You can also write a using (' Messager ', function () {}). This is written using the LoadModule () method to load the file. The module's JS and CSS will be loaded, as well as JS and CSS depending on the module.
Easyloader source code is relatively simple. Analysis of the source code, I use the wonderful taste of classroom Dupeng teacher Analysis of jquery method. Analysis of the following, relatively humble, the reason is not difficult, there is nothing to write.
* Easyloader [easyui_1.4.2]|-source {426} line. (function () {modules: {}//(199) locales: {}//(201, 224) Queues:loadjs ()://(2 244) Runjs ()://() Loadcss ()://loadsingle ()://(267, 307) LoadModule ()://(309, 371) Easyloader: {//(373, 403) modules: locales:base:theme:css:locale:timeout:load:onprogress:onload:}window.using = Easyloader.load; (415,)}) ();
Write a small example.
jquery-easyui-1.4.2
|-Locale
|-my
|-Demo1
|-test.html
|-Plugins
|-Themes
...
Test.html
<! DOCTYPE html>
jquery and Easyloader itself must be introduced. Other JS and CSS will not be introduced.
Easyloader is only loaded with Easyui volume sound customization. It can be used for research. Universal loading or learning to use require.js and sea.js
Easyloader [easyui_1.4.2] Analysis of the source code, hands even