【发布时间】:2010-11-17 05:50:12
【问题描述】:
我正在删除我的 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 函数。
请给点建议
【问题讨论】:
-
所有这些下划线!!啊啊啊啊啊啊!!!!!!
-
@jacob 我给了 _variablename 的私有变量
-
onready function of the same是什么意思?请详细说明您想要什么。
标签: javascript namespaces onready