我有一个bootstrap模式,当我显示模态时,我操作它来运行ajax jQUery。
$urlLocation = 'app/search';
$urlLocationJs = 'app/assets' . '/js/x3dom.js';
$urlLocationJs2 = 'app/assets' . '/js/scene3d.jquery.js';
$("#modal").on('shown.bs.modal', function () {
var form = $('#dynamic-form');
$.ajax({
url : '$urlLocation',
type : 'post',
data : form.serialize(),
success : function(response){
$.when(
$.getScript( '$urlLocationJs' ),
$.getScript( '$urlLocationJs2' ),
$.Deferred(function( deferred ){
$( deferred.resolve );
});
).done(function(){
var myCanvas;
myCanvas = $('#3dcanvas').scene3d({
width: "600px",
height: "400px",
ViewpointPosition : '3.5 -1 15',
});
myCanvas.addLine({x1:-5,x2:13,color:'#ff0000'});
}
});
});
});
案例是,当第一次加载(显示)模态时,由
调用的JavaScript$.when(
$.getScript( '$urlLocationJs' ),
$.getScript( '$urlLocationJs2' ),
$.Deferred(function( deferred ){
$( deferred.resolve );
})
).done(function(){});
已成功加载。 但不是第二个节目,第三个或连续不再加载脚本。
请告知。