正常に動作するSlimboxをインストールしました。
ただし、Slimbox の作成者はすべての Slimbox コードをラップし、いくつかのグローバル var を設定した後、var で DOM を初期化しています。
var Slimbox = (function() {
// Global variables, accessible to Slimbox only
var win = window, ie6 = Browser.ie6, options, images, activeImage = -1, activeURL, prevImage, nextImage, compatibleOverlay, middle, centerWidth, centerHeight,
// Preload images
preload = {}, preloadPrev = new Image(), preloadNext = new Image(),
// DOM elements
overlay, center, image, sizer, prevLink, nextLink, bottomContainer, bottom, caption, number,
// Effects
fxOverlay, fxResize, fxImage, fxBottom;
// now initialize the DOM
window.addEvent('domready', function() {
// *************
// This is where the problem arises.
// I call ajax actions here, and some functions which are external to 'domready'
// *************
pageInit();
setupFormSubmit('product_bid', 'afterPlaceBid');
setupAjaxAction('delete_validate_id_link', 'afterDelete');
setupAjaxAction('move_validate_down_link', 'afterMoveValidate');
//etc...
});
// end the DOM function
function afterMoveValidate(){
}
function afterDelete() {
}
// all the Slimbox functions are here too...
etc..
//end the var Slimbox
})
問題は、まだ var にある間、私の外部関数がグローバル スコープを持っていないのに、Slimbox 関数がグローバル スコープを持っていることです。
これは、DOM を初期化し、外部関数を持っていた Slimbox がなくても機能しました。
誰でもアイデア/説明を手伝ってもらえますか?
ありがとう