문제

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top