jQuery对话框第二次没有打开

时间:2014-04-28 04:59:27

标签: php jquery dialog

我正在使用jquery对话框在Edit上编辑产品。它是在第一个产品上开放但在第二个产品上没有,而我正在制作产品清单

以下是jquery对话框代码

$(function() {
    $( "#dialog-form" ).dialog({
        autoOpen: false,
        height: 570,
        width: 300,
        modal: true,
        buttons: {
            "Update": function() {
                window.location.href = '<?=base_url()?>cart/remove_cart_prod/';
        },
        Cancel: function() {
            $( this ).dialog( "close" );
        }
    },
        close: function() {
            allFields.val( "" ).removeClass( "ui-state-error" );
        }
    });

    $( "#edit-item" ).click(function() {
        $( "#dialog-form" ).dialog( "open" );
    });
});

最后是我的PHP代码

<div id="dialog-form" title="Edit <?=$prodname?>">
        <p class="validateTips">All form fields are required.</p>
        <form action="<?=base_url()?>cart/remove_cart_prod/" method="post">
          <fieldset>
            <label for="size">Size</label>
            <select id="size" name="size" onchange="calculate(this)">
              <option value="">Choose Your Size</option>
                <?php
                    $sizequery = $this->db->query("SELECT * FROM size WHERE product_id = " . $proddata->id . " and status = 1");
                    if($sizequery->num_rows() > 0) 
                    {
                        foreach($sizequery->result() as $row) 
                        {
                            $prodsize = $row->size_from .' x '. $row->size_to;
                ?>
              <option value="<?=$prodsize?>" id="<?=$row->price?>"><?=$row->size_from?> x <?=$row->size_to?></option>
              <?php } } ?>
            </select>
            <label for="quantity">Quantity</label>
            <select id="quantity" name="quantity" onchange="calculate(this)">
              <option value="">Choose Your Quantity</option>
                <?php
                    $query = $this->db->query("SELECT * FROM quantity WHERE product_id = " . $proddata->id . " and status = 1");
                    if($query->num_rows() > 0) 
                    {
                        foreach($query->result() as $row) 
                        {
                            for($i = $row->quantity_from; $i <= $row->quantity_to; $i++)
                            {   
                ?>
              <option value="<?=$i?>" id="<?=$row->discount?>">
              <?=$i?>
              </option>
              <?php } } } ?>
            </select>
            <label for="color">Color</label>
            <select id="color" name="color" onchange="calculate(this)">
              <option value="">Choose Your Color</option>
              <option value="2">2 Color</option>
              <option value="3">3 Color</option>
              <option value="4">4 Color</option>
            </select>
            <label for="shippint_time">Shiping Time</label>
            <select id="shipping_time" name="shipping_time" onchange="calculate(this)">
              <option value="">Choose Your Shipping Time</option>
              <option value="0">Normal Shipping FREE</option>
              <option value="100">Express Shipping 100$</option>
            </select>
          </fieldset>
          <div class="pricebox">
            <p>Product Price: <span>$</span><span id="product_price"></span></p>
            <p>Product Discount: <span>$</span><span id="product_discount"></span></p>
            <p>Total Price: <span>$</span><span id="result"></span></p>
          </div>
        </form>
      </div>
      <!-- end dialog box -->
      <div class="six columns" style="padding:0px;"><a href="javascript:void(0)" id="edit-item">Edit</a> | <a href="<?=base_url()?>cart/remove_cart_prod/<?=$item['rowid']?>" class="duplicate11" id="<?=$proddata->id?>">Remove</a> | <a href="<?=base_url()?>cart/duplicate_cart_prod/<?=str_replace(' ', '-', $prodname)?>/<?=str_replace(' ', '-', $item['size'])?>/<?=$item['qty']?>/<?=$item['price']?>/<?=$item['color']?>/<?=$item['shipping']?>/<?=$item['discount']?>" class="duplicate11" id="<?=$proddata->id?>">Duplicate</a></div>
当我点击&#34;编辑&#34;

时,

对话框应打开该特定对话框

1 个答案:

答案 0 :(得分:0)

执行代码$( "#dialog-form" ).dialog( "open" );后,#dialog-form DIV将从HTML中的原始位置移除,并附加在body元素的最后一部分。

即使元素移动到body元素的最后部分,你能检查#dialog-form DIV是否可以显示?

如果这不是问题的原因,如果没有javascript错误,你能看到javascript控制台吗?

  • 使用键盘快捷键Command - Option - J(Mac)或Control -Shift -J(Windows / Linux)。
  • 选择查看&gt;开发人员&gt; JavaScript控制台。