I want to migrate the javascript in my site from YU2 to YUI3, but I am only a poor amateur programer and I am stuck at the first pitfall.
I have the following code:
MyApp.Core = function() {
return {
init: function(e, MyAppConfig) {
if (MyAppConfig.tabpanels) {
MyApp.Core.prepareTabpanels(MyAppConfig.tabpanels);
}
},
prepareTabpanels: function(tabpanels) {
// Code here
}
}
}();
var MyAppConfig = {
"tabpanels":{"ids":["navigation"]}
};
YAHOO.util.Event.addListener(window, "load", MyApp.Core.init, MyAppConfig);
How can I pass the MyAppConfig
object to the MyApp.Core.init
function by using YUI3 "domready" event listener?
Thanks in advance!
You should be able to do something like:
Note that the event is not passed in as the first parameter, it is the config.
Y.on accepts parameters as
<event_type>
,<callback_function>
,<context>
,<params>
..any parameter after the third item is passed through to the callback function so MyAppConfig becomes the first parameter in your init.
EDIT See the YUI3 API documentation here: http://developer.yahoo.com/yui/3/api/YUI.html#method_on