Page is a not externally linkable
- Code, Content, and Presentation
-- JavaScript and AJAX
---- calling & defining functions using funcName() vs. window['funcName']()


Fotiman - 6:02 pm on Jan 4, 2013 (gmt 0)


Your particular problem is not what you think it is. The problem is that the callback function within ready() is asynchronous. It has nothing to do with whether the functions are defined as window['funcName'] or as function funcName().


Unfortunately, the defs must go in (doc).ready because they contain jQuery calls

jQuery calls do not need to be defined only in the ready method. The ready method just provides an alias of $ as the jQuery object, regardless of whether you've called noConflict. You could alternatively setup your own private alias.

Here's a jsfiddle that demonstrates it:
[jsfiddle.net...]

In the example, $ is defined before jQuery is included. In this example, $ is defined to just take a string and alert it (which is obviously different than what jQuery would do with it). This example demonstrates creating your own alias, but also shows where it's not safe to call a method defined in the ready method.


Thread source:: http://www.webmasterworld.com/javascript/4533285.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com