1
我試圖加載的lab.js
兩個街區在不同的地方,但如果我使用的功能在第二塊從第一塊加載的文件,它們顯示爲未定義。同時加載兩個腳本塊(使用lab.js作爲負載管理器)
這在第一塊(從我的MVC項目在報頭模板加載
<script>
$LAB
.script("<?php echo(GlobalConfig::$ROOT_URL); ?>scripts/jquery-1.10.2.min.js").wait()
.script("<?php echo(GlobalConfig::$ROOT_URL); ?>bootstrap/js/bootstrap.min.js").wait()
.script("<?php echo(GlobalConfig::$ROOT_URL); ?>bootstrap/js/bootstrap-datepicker.js").wait()
.script("<?php echo(GlobalConfig::$ROOT_URL); ?>scripts/libs/underscore-min.js").wait()
.script("<?php echo(GlobalConfig::$ROOT_URL); ?>scripts/libs/underscore.date.min.js").wait()
.script("<?php echo(GlobalConfig::$ROOT_URL); ?>scripts/libs/backbone-min.js").wait(function(){
$(document).ready(function(){
alert("loaded");
});
});
</script>
這是在一個內容模板加載從
$LAB
.script("../scripts/jquery-1.10.2.min.js").wait(function(){
$(document).ready(function(){
$(".test-badges").each(function(index) {
$(this).tooltip({
'show':true,
'placement': 'bottom',
'title' : 'Marca esta casilla si consideras que tu compañ[email protected] debe responder igual.'
});
});
});
});
的功能的第二塊第二個塊(.tooltip)沒有加載,因爲它們是jquery的依賴。沒有辦法統一兩個塊在只是一個塊加載在標題(這兩個文件完全獨立,並有內容動態創建,也不是我想要實現的)
所以問題是..有沒有辦法告訴第二個塊只在第一個塊完全加載時加載?
非常感謝!
我嘗試過了,它仍然給人一種語法錯誤。當然,錯誤來自$ lab的雙重聲明,但它仍然不能像那樣工作。我正在使用一個解決方法,現在定義jQuery的負載鏈,但它仍然不是一個好主意 – Cidwel
這很奇怪...你有一個jsfiddle的例子來玩嗎?此外,我討厭這樣建議,但我必須檢查:是不是在jQuery UI的.tooltip?你確定它被加載嗎? –