Ok, thanks for all your help...
If anyone else can provide any more insight on the differences between
those 2 pieces of code...
On Feb 23, 2:05 am, timothytoe [EMAIL PROTECTED] wrote:
I don't know if there's any practical difference. Maybe someone more
knowledgeable can chime it. Perhaps the
I bet if you asked on the jQuery development board, you'd get a good
answer. The people reading that one are more likely to understand the
internals.
On Feb 23, 4:59 am, Nazgulled [EMAIL PROTECTED] wrote:
Ok, thanks for all your help...
If anyone else can provide any more insight on the
On Feb 23, 12:14 am, Nazgulled [EMAIL PROTECTED] wrote:
Hi,
Let's say I have 2 different javascript files. I like to organize my
code that's why I use 2 different files so each file will only have
functions that fall into that file's category.
Anyway, here's the files layout...
file1.js:
Thanks...
And what's up with the:
(function($) {
// CODE
})(jQuery);
This was the thing that got me most confused when reading the
documentation. Can someone explain me this, what it does, what is for
and the best scenarios where would I need to use something like this?
If possible, explain
JavaScript has really expressive ways to call functions. The first
parentheses hide the function (make it anonymous) and the second
executes the code immediately with the parameter listed. I'm a newbie
myself, but I think that means right now, pass the variable jQuery in
as $ to the function and
And what exactly it means to hide a function, making it anonymous?
timothytoe wrote:
JavaScript has really expressive ways to call functions. The first
parentheses hide the function (make it anonymous) and the second
executes the code immediately with the parameter listed. I'm a newbie
The function doesn't have a name, so it doesn't pollute the namespace,
and it's great for making functions inline for handlers and
setTimeout() without the burden of having to make up a name that won't
even be referenced.
It's an outgrowth of everything being an object in JavaScript, and
being
timothytoe wrote:
The function doesn't have a name, so it doesn't pollute the namespace,
and it's great for making functions inline for handlers and
setTimeout() without the burden of having to make up a name that won't
even be referenced.
Can you give me an example of what you mean? I'm
Any time you create a function without a name it's anonymous. Example:
window.setTimeout(function() { alert('Hello world!') }, 60);
On Feb 22, 4:56 pm, Nazgulled [EMAIL PROTECTED] wrote:
timothytoe wrote:
The function doesn't have a name, so it doesn't pollute the namespace,
and it's great
I see, but...
How is this:
(function($) {
$.something = function() { alert('something'); }
$.test = {
abc: function() { alert('test'); }
}
})(jQuery);
Different from this:
jQuery.something = function() { alert('something'); }
jQuery.test = {
I don't know if there's any practical difference. Maybe someone more
knowledgeable can chime it. Perhaps the former ends up being a savings
in file size if you have a lot of functions.
On Feb 22, 5:44 pm, Nazgulled [EMAIL PROTECTED] wrote:
I see, but...
How is this:
(function($) {
11 matches
Mail list logo