English 中文(简体)
页: 1 装饰页数是两页,但为什么?
原标题:jQuery loads page twice but why?
  • 时间:2011-10-06 14:16:30
  •  标签:
  • jquery

我有一条航道,一把一页装入一个叫干的目标。 它运作良好,但稍有变化。

当我打着一丝网时,它隐藏了目前的内容,并装上了新内容,然后隐藏了新内容并再次显示新内容。 在大火中,一看到该笔文字对试图装载的那页提出了两项要求。 但我不能理解为什么它装上了两倍?

这里我 j:

$(".nav").click(function(e){
        e.preventDefault();

        $(".footer").hide(0);       
        $( #target ).html( <div class="content">Loding...</div> );

        $.get(this.href, function(data) {

            $("#target").hide(0, function(){
                $("#sub_menu").fadeOut("fast");     
                $(".footer").show(0);
                $(this).html(data).show(0);
            });

        }); 


});

regards!

最佳回答

这是我对《任择议定书》的评论:

• 确保你关于点击的代码仅为ONCE

问题回答

我的猜测是,你将用“nav”的2个元素。

Try alert($.nav”);length;,以检查你有多少精英。

The chances are your event is bubbling up from the actual event target and the handler is bound to an ancestor, in which case it will fire twice.

您可以通过打电话<条码>推广来阻止这种情况发生。 2. 活动目标的方法:

$(".nav").click(function(e) {
    e.stopPropagation();
    //etc...
});

出现这种情况有几个原因,但首先可以做一些不同的事情来预防。 首先,确保你在装满通过日本宇宙航空研究开发机构装满内容时不再重新申请操作员。 内容上的任何文字只能适用于装满的内容。 第二,如果你怀疑你可能重新申请操作员,或需要更换现有的手稿,则在适用新程序之前将事件的操作者除名。 第三,当你知道被援引的手应当是唯一可以阻止传播的内容的人,并酌情防止缺席行动。 这样做的最容易的方法是从你的手稿中填回<>false。

 $( .nav ).unbind( click ).click( function() {
     ...
     return false;
 });




相关问题
getGridParam is not a function

The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...

selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

jQuery cycle page with links

I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

jConfirm with this existing code

I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...

Wrap text after particular symbol with jQuery

What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...

热门标签