Friday, May 29, 2009

[jQuery] Re: calling functions between multiple document ready events

There's just so much in JQuery. I will give the name spacing a try :)
thanks.

On Sat, May 30, 2009 at 6:27 AM, MorningZ <morningz@gmail.com> wrote:

"If i make a custom function my site uses a lot. i put it in a
plugin. :) "

Why not fake a namespace instead?

like if you had

function toUpperCase() {
  //your custom "to upper case" code that
  //would conflict with JS's verion
}

simply saying

var waseem = {};
waseem.toUpperCase = function() {
  //your custom "to upper case" code that
  //would no longerconflict with JS's verion
}

would solve the issue....



back on topic, i haven't seen anyone suggest that the original code

$(function(){
  function displayMessage(){ alert('hello world'); };
});
$(function(){
 displayMessage();
});

be written like

function displayMessage(){ alert('hello world'); };

$(function(){
 displayMessage();
});
$(function(){
 displayMessage();
}

});

which makes a lot of sense, and is a super simple change

No comments: