【问题标题】:After jquery auto refresh a div popup doesnt work在 jquery 自动刷新后,一个 div 弹出窗口不起作用
【发布时间】:2017-03-28 17:50:53
【问题描述】:

我有一个刷新 div 的 jquery,但刷新后弹出窗口无法从刷新的数据中工作。

<script type="text/javascript">
    $(function() {
        $.ajaxSetup ({
            cache: false
        });
        //Refresh trigger `#newORDERx`
        var auto_refreshes = setInterval(function () {$('#newORDERx').load('inc/restAdmin_orders_rcvz.php');}, 1000);
    });
</script>
<div id="newORDERx"></div>

当我像下面这样使用它时,弹出窗口可以正常工作,但它不会刷新 div。

<script type="text/javascript">
    $(document).ready(function(){
        $.ajaxSetup ({
            cache: false
            mainClass: 'pp-product-detail' // when i use this then popup works but then doesn't refresh the div
        });
        var auto_refreshes = setInterval(function () {$('#newORDERx').load('inc/restAdmin_orders_rcvz.php');}, 1000);
    });

</script>

pp-产品详细信息类

AJAX popup

if ($('.pp-product-detail').length) {
   $('.pp-product-detail').magnificPopup({
       type: 'ajax'
   });
}

restAdmin_orders_rcvz.php

<div class="col-lg-6">
  <div class="the-menu-item">
    <div class="image-wrap">
      <a class="pp-product-detail" href="product-detail-popup-rest-admin-order-rcv.php?iid=<?php echo $phporder; ?>">
      <img src="images/themenu/img-1.jpg" alt="">
      </a>
    </div>
    <div class="the-menu-body">
      <b><font color='red'> Order # </font> <?php echo $phporder; ?><br>
      <font color='red'> Items Included : </font> <?php echo $lrsa['count']; ?>
      <br><font color='red'>Dated : </font> <?php echo date("d/m/Y", strtotime($phpdates)); ?>
      </b>
    </div>
  </div>
</div>

【问题讨论】:

  • 我看不到弹出触发器在哪里...但我想它在#newORDERx... 因为这个元素被“刷新”或重写,所以元素触发弹出窗口也是如此。您只需要修改事件处理程序(您没有提供):$("#popupTrigger").on("click",function(){...}$(document).on("click","#popupTrigger",function(){...}
  • 什么“弹出”?什么是“弹出”,是什么导致它“弹出”?
  • pp-product-detail 类是什么?
  • 那就展示吧! ;)
  • @LouysPatriceBessette 检查更新

标签: javascript php jquery partial-page-refresh


【解决方案1】:

好的...我很确定问题出在您的class 上,因为您重新编写了.pp-product-detail 元素...

所以试着把它改成这样:

if ($(document).find('.pp-product-detail').length) {
   $(document).find('.pp-product-detail').magnificPopup({
       type: 'ajax'
   });
}

【讨论】:

  • 还是一次打开弹窗,多次打开url中的文件
  • 嗯...你有实时链接可以分享吗?
  • 哈!您确定能够在本地环境中执行 ajax 请求吗?现场试用...这可能是问题所在。
  • 如果我不刷新它,它工作正常,只是它在我刷新 div 时引起
【解决方案2】:

我刚刚在restAdmin_orders_rcvz.php 中添加了以下文件,并且工作正常。

<script type="text/javascript" src="js/scripts.js"></script>

restAdmin_orders_rcvz.php

<div class="col-lg-6">
  <div class="the-menu-item">
    <div class="image-wrap">
      <a class="pp-product-detail" href="product-detail-popup-rest-admin-order-rcv.php?iid=<?php echo $phporder; ?>">
      <img src="images/themenu/img-1.jpg" alt="">
      </a>
    </div>
    <div class="the-menu-body">
      <b><font color='red'> Order # </font> <?php echo $phporder; ?><br>
      <font color='red'> Items Included : </font> <?php echo $lrsa['count']; ?>
      <br><font color='red'>Dated : </font> <?php echo date("d/m/Y", strtotime($phpdates)); ?>
      </b>
    </div>
  </div>
</div>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-09
    相关资源
    最近更新 更多