简体   繁体   English

太多的递归jQuery

[英]too much recursion jquery

I've got an issue of too much recursion with jquery and in IE a pop up stack overflow, what it can be? 我有一个与jquery过多递归的问题,并且在IE中弹出堆栈溢出,这可能是什么?

Here my code 这是我的代码

Html : HTML:

<div id="leiki_tabs">
<div id="leiki_container">
<ul id="leiki_menu">
  <li style="width:100px;border-right:1px dotted #333;border-bottom:1px dotted #333;text-align:center;"><a id="title_leiki_panel_1" href="#" rel="leiki_panel_1">Today</a></li>
  <li style="width:100px;border-right:1px dotted #333;border-bottom:1px dotted #333;text-align:center;"><a id="title_leiki_panel_2" href="#" rel="leiki_panel_2">This Month</a></li>
  <li style="width:100px;border-right:1px dotted #333;border-bottom:1px dotted #333;text-align:center;"><a id="title_leiki_panel_3" href="#" rel="leiki_panel_3">Archive</a></li>

  <li style="width:270px;"/>
  <li id="leiki_logo_tab_menu"><a href="#" rel="leiki_panel_5" ><img id="leiki_logo" style="border:0px;" src="leikiLogo_onMouseOver.png"/></a></li>
</ul>
</div>

<!--Panel Contents Start-->
<div id="leiki_panel_1" class="leiki_panel">
  <ul class="leiki_panel_ul">
    <li class="leiki_panel_li"><div class="leiki_left"><Article 1</div></li>
    <li class="leiki_panel_li"><div class="leiki_left">Article 2</div></li>
    <li class="leiki_panel_li"><div class="leiki_left">Article 3</div></li>
    <li class="leiki_panel_li"><div class="leiki_left">Article </div></li>
    <li class="leiki_panel_li"><div class="leiki_left">Article 5</div></li>
  </ul>
</div>

Javascript : Javascript:

var opened_one = null;
$(function(){
    $('div[id*="leiki_panel"]').hide();
    $('div[id="leiki_panel_1"]').show();
    $('#title_leiki_panel_1').addClass("leiki_menu_highlight");
    $('#leiki_menu a').mouseenter(function(){
        $('a[id*="title_leiki_panel"]').removeClass("leiki_menu_highlight");
        if(opened_one==null){$('div[id="leiki_panel_1"]').hide();}
        $(opened_one).hide();
        var link_rel = $(this).attr('rel');
        $('div#' + link_rel).show();
        opened_one = $('div#' + link_rel);
        var tab = "title_" +link_rel;
    }).mouseleave(function(){
        var link_rel = $(this).attr('rel');
        var tab = "title_" +link_rel;
        if(tab=="title_leiki_panel_1" ||
        tab=="title_leiki_panel_2" ||
        tab=="title_leiki_panel_3" ||
        tab=="title_leiki_panel_4" ||
        tab=="title_leiki_panel_5"){
        $("#"+tab).addClass("leiki_menu_highlight");}
    });
});

It's working on my desktop without problem but on the test server which is owned by our customer it give me this error too much recursion. 它可以在我的桌面上正常工作,但是在我们的客户拥有的测试服务器上,它给我带来了太多的递归错误。 I cant post the address of the test server but maybe in private message. 我无法发布测试服务器的地址,但可能在私人消息中。

Cheers 干杯

Try changing $('#leiki_menu a').mouseenter(function() and similar into: 尝试将$('#leiki_menu a').mouseenter(function()等更改为:

$('#leiki_menu').delegate('a', 'mouseenter', function(){
    // ...
}).delegate('a', 'mouseleave', function(){
    // ...
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM