小编Ger*_*rtV的帖子

用ajax加载后无法在DOM中找到元素(想要将jquery插件绑定到它)

所以我有2个html页面.1用作容器,1用作内容.当我用表格加载内容页面时,我可以使用拖放操作.

但是当我转到我的容器页面并将内容页面加载到带有ajax的div时,拖放工作就停止了.内容页面中的所有其他JavaScript功能仍然有效.如何将jquery dnd插件绑定到加载ajax的表?

我正在使用拖放作为教程http://isocra.com/2008/02/table-drag-and-drop-jquery-plugin/

我的代码看起来像这样:

$(window).load(function()
{   if(temp == 0)
    { 
        DP("eerste keer")
        load_table(); 
        temp = 1;
    }
} );

function load_table()
{    
    DP('load_table');
    $.ajax({
            //async: false,
            type: "POST",
            url: "/diagnose_hoofdpagina/table_diagnose/" + DosierID, // <== loads requested page
            success: function (data) {
                    $("#diagnoses_zelf").html(''); //<== clears current content of div
                    $("#diagnoses_zelf").append(data).trigger('create'); // <== appends requested page
                },
            error: function(){
                alert('error');
              } 
        }).done(function() {
        update_table(); 
        initialize_table();    // <== calls jquery plug in
        });

    return false;   
}


function initialize_table() 
{
    var tableid …
Run Code Online (Sandbox Code Playgroud)

html javascript ajax jquery dom

15
推荐指数
1
解决办法
2万
查看次数

标签 统计

ajax ×1

dom ×1

html ×1

javascript ×1

jquery ×1