I have used confirmation inside a Jquery acordin. main tabs of acordin are Categories and in side there is Items. User can delete both Items and Categories(of course different tables and models).
Now when I click on delete category it asks should it delete or not …Till now everything is fine but as long as I click cancel AND category has Items in its panel confirm repeats itself for number of items time. following is my code. Please help me out
Following Image will illustrate what I mean
<?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
?>