0

在 setInterval 中的 ajax-call-load 立即执行后,所有折叠出来的元素都有问题,所有折叠出来的东西都会自动折叠起来。如果没有命令折叠,它应该保持折叠

任何想法 ?

注意:我已经通过在 setInterval 中禁用 ajax-call-load 进行了测试,并且所有折叠出的都不会变成折叠入。引导程序 2.3.2

Example:
<div id="totalmessage"></div>
<div id="totalmessage1"></div>
<div data-toggle="collapse" data-target="#collout" class="btn btn-small">expand</div>

<div id="postdata">Click to Post</div>

<div class="collapse out" id="collout">
My collapsed out data and refreshed after postdata clicked
</div>

<script type="text/javascript">
$('#postdata').click(function(e){
       e.preventDefault();
       $.ajax({
                    type : "POST",
                    url : "/comments.php?jfocode=add&ajax=true",
                    data : { content : 1234 },
                    success : function(data) {
                             //reload data seamesly
                             $('#collout').html(data);
                    }
      });
      return false;
});

setInterval(function(){
        $.ajax({
            type : "GET",
            dataType: "json",
            url : '/message.php',
            data : 'jfocode=getmsgcount&location=INBOX&status=NEW&ajax=true',
            success : function(data) {
                $('#totalmessage').ajaxComplete(function(event, request, settings){
                    if (data.totalmessage)
                    {
                        $('#totalmessage').html(data.totalmessage);
                        $('#totalmessage1').html(data.totalmessage);
                        if (data.totalmessage > 0)
                        {
                            $('#totalmessage').show();
                            $('#totalmessage1').show();
                        }
                        else
                        {
                            $('#totalmessage').hide();
                            $('#totalmessage1').hide();
                        }
                    }
                });
            }
        });
        return false;
    }, 10000);
</script>
4

1 回答 1

0

尝试使用 event.stopPropagation(); 在成功调用 ajax 以防止可折叠的“折叠入”之后

于 2013-08-12T12:40:39.730 回答