Written by Arash Karimzadeh |
Sunday, 15 March 2009 12:03 |
Include JS and CSS in a sequence. This plugin let you to include files as chain and is now merged with $.includeMany which you can find out more about it by reading this article or just reading the chainclude functionality in this article. IncludeMany plugin version 1.2.0 and upper now support this functionality.
The syntax is easy:
$.chainclude(files,[finalCallback]);
Download includeMany (+chainclude)
You can get it here or check this article for the latest version.
Chainclude (include css and js sequentially)
Parameters
Can be
- List of files such as ['fileurl1','fileurl2',...,'fileurln']
- Key/value object of files such as {'fileurl1':callback,'fileurl2':callback,...,'fileurl2':callback}
-
finalCallback [function] optional
Is a function which will be called after all files are loaded and all callbacks have been called
Examples
- The simplest format is:
-
$.chainclude( ['js1.js','scripts/js2.js'] ,someOptionalFunction);
%24.chainclude%28%20%5B%27js1.js%27%2C%27scripts%2Fjs2.js%27%5D%20%2CsomeOptionalFunction%29%3B
You can avoid someOptionalFunction.
- You can define a callback for each file
-
$.chainclude(
-
{
-
'script1.js':function(){ /*something*/ },
-
'script2.js':function(){ /*something*/ }
-
}
-
);
%24.chainclude%28%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%27script1.js%27%3Afunction%28%29%7B%20%2F%2Asomething%2A%2F%20%7D%2C%0A%20%20%20%20%20%20%20%20%27script2.js%27%3Afunction%28%29%7B%20%2F%2Asomething%2A%2F%20%7D%0A%20%20%20%20%7D%0A%29%3B
Sample File
You can download the sample file here.
Tags: includeMany | jQuery
|
Last Updated on Sunday, 26 September 2010 10:54 |