0

我有一个加载到 document.ready 的插件比率(http://wbotelhos.com/raty),页面内容在单击重新加载 DOM 的一部分的按钮时发生变化,并且文档尚未准备好“重新计算”而且我不会重新加载所有javascript(还有其他类似的行为)我尝试了这个解决方案但没有成功

function star(){
alert("star");
...code plugin...
}

$(document).ready(function() {
    star();
});

$.ajax({
        ..code.. 
        done: function(creaStella) {
            alert("D");
            star();
        },
        complete:function(){
            alert("C");
star();
        },

    });

调用 ajax 后我有 alert("star") 但我没有填充我的 div

4

2 回答 2

0

$.ajax 的错误使用

 $.ajax({
    ..code..
    success: function(creaStella) {  
         //code to populate div goes here
        alert("complete");
        star();
    }
}).done(function(){
    //or here
   alert("complete2");
 });

使用成功/完成作为表演(或两者)。

于 2013-09-07T12:00:15.963 回答
0

我以这种方式解决..(promise().done) 也使用 jquery validate 插件在 dosen 不起作用之前形成

function star(){
    //plugin star    
}

$(document).ready(function() {
    formJqueryValidate1();
    formJqueryValidate2();
    star();
});


function formJqueryValidate1() {
    //my check

function formJqueryValidate2() {
    //my check
}


$.ajax({

    success: function(msg) {
        $('#myid').html(msg.template).promise().done(function(){
            formJqueryValidate1();
            formJqueryValidate2();
            star();
        });
    }

}

});
于 2013-09-07T13:23:43.537 回答