2011-12-28 57 views
1

found如果它被刪除嗎?那CStarRating導致此錯誤得到ok.Also CStarRating使頁面呈現非常緩慢,再加上它也導致其他jQuery插件出現故障了CHtml ::鏈接確認重複的Yii

我已經使用確認內Jqueryacordin。 acordin的主標籤是Categories,並且在側面有項目。用戶可以刪除項目和類別(當然不同的表格和模型)。

現在,當我點擊刪除類別時,它會詢問是否刪除或刪除.....直到現在一切正常,但只要點擊取消並且類別已在其面板中的項目確認重複自身的項目數量。以下是我的代碼。請幫我出

Image將說明我的意思enter image description here 感謝

<?php 
foreach($model->categories as $Category){ 
     echo CHtml::link('<span id="add_new_item">Add New Item </span>', array('items/create','id'=>$Category->id)); 
     echo ' <span id="update_del_category">'; 
     $image = CHtml::image('/Hunt2Eat/assets/b4e73c2b/gridview/update_item.png', 'Update', array('class' => 'view')); 
     echo 'Edit'; 
     echo CHtml::link($image, array('category/update', 'id'=>$Category->id)); 
     $image = CHtml::image('/Hunt2Eat/assets/b4e73c2b/gridview/delete_item.png', 'Delete', array('class' => 'view')); 
     echo ' Delete'; 
     echo CHtml::link($image,'#',array('submit'=>array('category/delete','id'=>$Category->id),'confirm' => 'Are you sure you want to delete '.$Category->name.'?')); 

    echo '</span> 
      <ul style="width:99%;" id="menu3" class="menu noaccordion"> 
      <li style="width:100%; "> 
       <a href="#" style="color:white; padding:6px 0 6px 5px;">'.$Category->name.'</a> 
        <ul style="width:99%"> 
         <div id="item_headings"> 
          <label id="item_name"> Name </label> 
          <label id="item_price"> Price (PKR)</label> 
          <label id="item_rating"> Rating </label> 
         </div>'; 

foreach($Category->items as $Item) 
    { 
    echo '<div id="update_del_item">'; 
    echo CHtml::link('Edit', array('items/update', 'id'=>$Item->id)); 
    echo '</div> 
       <div id="update_del_item">'; 
    echo CHtml::link('Delete','#',array('submit'=>array('items/delete','id'=>$Item->id),'confirm' => 'Are you sure?')); 
    echo '</div> 
       <li > 
       <a href="#" name="Item"> 
        <div style="height:20px; width: 360px;"> 
         <span id="item_list">'.$Item->name.'</span> 
         <span id="item_list">'.$Item->price.'</span> 
         <span style="float:right;">'.$this->renderPartial('_rating',array('model'=>$model),TRUE,TRUE).'</span> 
        </div>  
       </a>     
      </li>'; 
}//For Loop to Extract category Items from category Array 
    echo 
      '</ul> 
     </li> 
    </ul>'; 
}//For Loop to Extract Categories from Hotel array 

?> 

回答

1

我認爲這個問題是從jQuery的多個事件的代表團。 對於

echo CHtml::link('Delete','#',array('submit'=>array('items/delete','id'=>$Item->id),'confirm' => 'Are you sure?')); 

Yii框架會給錨的唯一id和在HTML寄存器一塊的JavaScript(jquery的)的爲:

jQuery('body').undelegate('#yt0', 'click').delegate('#yt0', 'click', function() { 
    if (confirm('Are you sure?')) { 
     jQuery.yii.submitForm(this, '/index.php/items/delete/4', {}); 
     return false; 
    } else return false; 
}); 

其中YT0是分配了唯一的ID。通常不會有問題,因爲它首先會取消清除。你能檢查由Yii註冊的javascript嗎?