2011-09-28 20 views
0

我試圖將頁面加載到模態窗口中。我更願意使用它加載必要的js文件,而不是在head中調用它們,以便爲每個頁面加載它們,包括不需要的頁面。MochaUI不會在窗口中加載腳本src

問題是我無法獲取要加載的腳本。似乎有些東西阻止他們工作。我將evalScripts設置爲false,並將loadMethod更改爲xhr,因爲文檔說evalScripts選項是xhr的一個選項。注意:在我更改爲xhr和evalScripts之前它沒有工作:false。

這裏是呼叫:

MUI.newthingWindow = function() { 
    new MUI.Modal({ 
     id: 'newthing', 
     title: 'New Thing',   
     contentURL: '/things/newThing/1', 
     type: 'modal', 
     loadMethod: 'xhr', 
     evalScripts: false, 
     width: 600, 
     height: 600, 
     padding: { top: 43, right: 12, bottom: 10, left: 12 }, 
     scrollbars: false 
    }); 
}; 
if ($('newThingLink')) { 
    $('newThingLink').addEvent('click', function(e){ 
     new Event(e).stop(); 
     MUI.newthingWindow(); 
    }); 
} 

任何線索?

坦克

回答

0
evalScripts: false, 

必須

evalScripts: true, 

允許網頁上的腳本工作,但通過script src加載外部腳本仍然沒有骰子。雖然,這將允許一個js加載器(使用jQuery btw「jq」)。

<script type="text/javascript" charset="utf-8"> 
jq.getScript('/assets/js/things/new_thing.js', function(data, textStatus){ 
    console.log(data); //data returned 
    console.log(textStatus); //success 
    console.log('Load was performed.'); 
}); 
</script>