简体   繁体   中英

calling function defined in onDomReady

Below is my sample js in which everything is defined inside doDomReady function their are multiple function their. `

YAHOO.namespace("YAHOO.User");
YAHOO.User = (function() {
Event.onDOMReady(UserData = function() {
.......
function save(){}
..........
});

})();`

From the above js file I want to call the save method from outside(from other js file) like this ->YAHOO.User.save(resultset) but I am not able to call it since it is not visible.

Anyone tell me how to call the functions in above case.

window.save == function(resultset){ ... }

This puts it in the global scope, so you could just call save() from another script. To namespace it under YAHOO.User, I suppose it would be:

window.YAHOO.User.save = function(resultset){ ... }

... then you can call YAHOO.User.save(resultset) from outside.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM