gpt4 book ai didi

用于调用 Namespace 函数的 Javascript Onready 函数

转载 作者:行者123 更新时间:2023-12-04 17:04:59 25 4
gpt4 key购买 nike

我正在删除我的 Rails/views/show.html.erb 中使用的 Javascript 中的全局变量

我正在使用的 javascript 是

var App = {};
App.UserSnapShot = function () {
var _body, _detailEl, _selectedLinkEl;

var _init = function () {
_body = $$("body")[0];

$$(".user-link").each(function (el) {
el.observe("mouseover", function (event) {
_selectedLinkEl = el;
_detailEl = event.element().next();
_detailEl.show();
_body.observe("mouseover", _bodyMouseOverFunction);
});
});
};

var _bodyMouseOverFunction = function (event) {
if (event.element() != _selectedLinkEl &&
event.element() != _detailEl &&
!event.element().ancestors().include(_detailEl)) {
_detailEl.hide();
_body.stopObserving("mouseover", _bodyMouseOverFunction);
}
};

return {
init: function () {
_init();
}
};
}();

我需要调用我的函数 App.UserSnapShot.init(); 通过相同的 onready 函数 .. ,以便让它工作..
如何在此处添加 onReady 函数。

请给一些建议

最佳答案

你的意思是?

App.onReady = function() {
App.UserSnapShot.init();
};

document.observe("dom:loaded", App.onReady);

关于用于调用 Namespace 函数的 Javascript Onready 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4201859/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com