A js/css template is provided to me.
It is very talented in interactive event handling, but i am not talented on js/jquery.
In its js library, there is a .js file,
and the file has some code like:
(function ($) {
...
})(jQuery);
most of thing happens in it.
There are some “little independent functions” in this upper function.
And some lines in this upper/wrapper/non-named function, call these “little-independent functions”.
Also, i want to call these “little independent functions” BUT i could not find out how.
Because in the lines in “(function ($) {...})(jQuery);” those call these “little independent functions” there are some local variables.
I think some code help me to tell:
(function ($) {
if(...){
var items;
addItem(items)
}
function addItem(funcitems){}
...
})(jQuery);
My question is that, how can i call additem, how can i pass “items” into it?
I want to call it in a custom part of my page after a custom event.
You have two options to achieve this:
1) Add your code into this anonymous function, so that your code is in the same scope like these encapsulated functions. (Not so good since you are compromising the library)
2) Make a variable assignment and add a return-statement with the functions you need: (better, since you dont mix the library code with your own and just expose a few of the functions)
Now you can access the
addItemfunction by callingextLib.addItem(item).