我正在研究一个使用 JScroll 的 js 文件。事件的回调jsp-scroll-y
在以下函数中定义
function initWall() {
//callback from jqueryscrollpane
Scroll_TimeLine_Instance = function (event, scrollPositionY, isAtTop, isAtBottom){
//get more content
if (isAtBottom) {
GetMoreDate(objid, vwrsid, secid, orgid, incflwr, qty, mintlid, maxtlid, successGetTimeLineCallback, failureGetTimeLineCallback);
}
}();
}
定义了另一个函数,然后将此回调绑定到 jsScroll
function reapplyScroll() {
Utilities.DestroyScrollBar($(_target).closest('.widgetBody'));
Utilities.ApplyScrollBar($(_target).closest('.widgetBody'), false, Scroll_TimeLine_Instance);
}
Utilities.ApplyScrollBar = function (element, showScrollBar, scrollCallback) {
$(element).jScrollPane({
horizontalGutter: 5,
verticalGutter: 5,
'showArrows': false
}).bind('jsp-scroll-y', scrollCallback);
if (!showScrollBar) {
$(element).find('.jspDrag').hide();
}
}
回调从未被调用,我发现这是因为它未定义。如果我删除Immediate object initialization
(); 从创建功能后,一切正常。
谁能解释一下?我不明白为什么它被立即调用,所以我认为这是创建它的人的错误,我不知道为什么它会导致这个变量未定义?