jQuery-刷新后,DIV中的功能不起作用 [英] Jquery - Function Inside DIV not working after refreshed

查看:71
本文介绍了jQuery-刷新后,DIV中的功能不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个表"group1",其中包含表和行.我使用此插件(tableDnD)上下拖动行,并且一切正常.我还有另一个Jquery函数,它删除DIV"group1"内的行并仅刷新DIV,这也可以正常工作.

I have a table "group1" contains table and rows. I use this plugin (tableDnD) to drag the row up/down, and it is all working fine. I have another Jquery function that delete row inside the DIV "group1" and the refresh the DIV only, this also works fine.

    $('#group1').tableDnD({
    onDrop: function(table, row) {      
        $.post('updateRecord.asp?', {
            pagesid : "1",
            arr : $.tableDnD.serialize()
        }); 
    }
});

现在,在删除行之后,更新数据库,然后刷新DIV,上面带有选项上下拖动行的jQuery将不再起作用(如果我刷新整个页面,它将起作用).我做了一些研究,发现有人建议使用委托选项,但是我不确定如何应用于$('#group1').tableDnD函数.

Now, after the rows deleted, updated DB, then refreshed the DIV, the jQuery above with option drag row up/down is no longer working (if I refresh entire page, it would work). I did some research and see people suggested about using delegate option, but I am not sure how to apply to the $('#group1').tableDnD function.

已更新-我尝试过,但是没有运气.

Updated - I tried this, but no luck.

$(document).on('tableDnD', '#group1', function(){
onDrop: function(table, row) {      
    $.post('updateRecord.asp?', {
        pagesid : "1",
        arr : $.tableDnD.serialize()
    }); 
}

});

任何建议将不胜感激.

推荐答案

您可以创建自己的事件并调用

You could create your own event and call it

 $('body').on('apply_tableDnD', '#group1', function() {
  $('#group1').tableDnD({
    onDrop: function(table, row) {
      $.post('updateRecord.asp?', {
        pagesid: "1",
        arr: $.tableDnD.serialize()
      });
    }
  });
});

这将在刷新div后调用

This will call after div has been refreshed

$('#group1').trigger('apply_tableDnD');

这篇关于jQuery-刷新后,DIV中的功能不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆