简体   繁体   English

在onDomReady中定义的调用函数

[英]calling function defined in onDomReady

Below is my sample js in which everything is defined inside doDomReady function their are multiple function their. 下面是我的示例js,其中所有内容都在doDomReady函数中定义,它们是它们的多功能。 ` `

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. 从上面的js文件,我想像这样-> YAHOO.User.save(resultset)从外部(从其他js文件)调用save方法,但是由于它不可见,所以我无法调用它。

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. 这将其置于全局范围内,因此您可以仅从另一个脚本调用save() To namespace it under YAHOO.User, I suppose it would be: 为了在YAHOO.User下对其命名空间,我想是:

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

... then you can call YAHOO.User.save(resultset) from outside. ...然后您可以从外部调用YAHOO.User.save(resultset)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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