Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/85.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 通过ajax添加内容,但mouseenter事件无效_Jquery_Django_Dajaxice_Dajax - Fatal编程技术网

Jquery 通过ajax添加内容,但mouseenter事件无效

Jquery 通过ajax添加内容,但mouseenter事件无效,jquery,django,dajaxice,dajax,Jquery,Django,Dajaxice,Dajax,有一个html表格,在每一行,我添加了“编辑”图标,当鼠标进入图标,它会弹出一个菜单。 在document.ready函数中,事件mouseenter有效。 但是如果我通过dajax添加新行,mouseenter事件将无效 function add_finding(table_type){ if(!check_finding_attribute(table_type)) return; else{ Dajaxice.codeinsight.add_finding(Dajax.proces

有一个html表格,在每一行,我添加了“编辑”图标,当鼠标进入图标,它会弹出一个菜单。 在document.ready函数中,事件mouseenter有效。 但是如果我通过dajax添加新行,mouseenter事件将无效

function add_finding(table_type){
if(!check_finding_attribute(table_type))
    return;
else{
Dajaxice.codeinsight.add_finding(Dajax.process,get_finding_attribute_dict(table_type));
    reset_finding_attribute(table_type);
    //reload the popup menu
    $(".menubox").each(function(){
        var menubox_id=$(this).attr("id");
        var showmenu_id=menubox_id.replace("menubox","showmenu");
        $.showmenu("#"+showmenu_id,"#"+menubox_id);
    });
}
}

$(document).ready(function(){
jQuery.showmenu = function(showbtnid,showboxid) {
    var showmenubtn = $(showbtnid);
    var showmenubox = $(showboxid);
    showmenubtn.mouseenter(function(e){
        var thish = $(this).height();
        var offset = $(this).offset();
        var tipx = offset.left;
        var tipy = offset.top+thish-1;
        showmenubox.show().css("left",tipx).css("top",tipy);
        t= setTimeout(function(){showmenubox.hide();},1000);
      });
    showmenubox.mouseenter(function(){
        clearTimeout(t);
    });
    showmenubox.mouseleave(function(){
        $(this).hide();
    });
};
$(".menubox").each(function(){
    var menubox_id=$(this).attr("id");
    var showmenu_id=menubox_id.replace("menubox","showmenu");
    $.showmenu("#"+showmenu_id,"#"+menubox_id);
});
});

如果内容是通过AJAX提供的,并且您也希望将事件绑定到它,那么您应该这样做

jQuery.on(...)
正常的事件绑定将不适用于这些

jQuery.on("mouseenter", showbtnid,function(){...})
上述绑定将在将来处理现有元素以及新添加的元素

快乐编码:)