Yii Framework Forum: CHtml::link Confirm repeats Yii - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

CHtml::link Confirm repeats Yii CHtml::link Confirm repeats Yii Rate Topic: -----

#1 User is offline   Riaz Khan 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 9
  • Joined: 17-December 11

Posted 28 December 2011 - 06:40 AM

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 Posted Image
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>

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>
}//For Loop to Extract category Items from category Array
}//For Loop to Extract Categories from Hotel array



Share this topic:

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users