Jquery And Javascript Namepsace
In trying to namespace my js/jquery code, I have come up against the following problem. Basically, I used to write all my JS code in each html/php file, and I want to abstract that
Solution 1:
$(document).ready(productActions.init());
This code calls init()
immediately and passes its return value to ready(...)
. (just like any other function call)
Instead, you can write
$(document).ready(productActions.init);
To pass the function itself. Howeverm this will call it with the wrong this
; if you need this
, write
$(document).ready(function() { productActions.init() });
Post a Comment for "Jquery And Javascript Namepsace"