I have an actionListCategory, in this action, I render a view (listCats) wich display all cats with ajax delete button for each cat.
When I click on the delete button, it call the actionDeleteCat (ajax), this action will delete the cat from database, and then render listCats to display the list of cats after deleted.
This is OK but now I click on another delete button, nothing happens
here my code:
CatController.php
public function actionListCategory()
{
$cats=Cat::model()->findAll();
$this->render('listCategory',array('cats'=>$cats));
}
public function actionDeleteCat()
{
Cat::model()->deleteByPk($_GET['id']);
$cats=Cat::model()->findAll();
$this->renderPartial('listCats',array('cats'=>$cats));
}
?>
Well, i’m not sure about ajaxButton (i didn’t use it yet), but probably it’s same as at common jquery(and etc) issue: when u load full page - u render and set ‘events’ that request ajax content. But when u load new content, no events set for that, so u have to solve it somehow - for example, manually set events.
for example:
u have list of links:
<a href ="#">…
<a href ="#">…
<a href ="#">…
<a href ="#">…
and ur application auto setup click events for these links.
but after some click, u load another part of links(via ajax) and u got:
<a href ="#">…
<a href ="#">…
<a href ="#">…
well, if content(links in our case) came as raw html for our ajax request, then no events for that content. U have to solve it somehow. probably execute ‘event binder’.
it’s how it’s working in theory. I’m not sure about ajaxButton at yii and ajax content, but it’s more important to understand how it’s working in reality. try to look at ur source after full page load and look for any event binders…probably u will find ur solution there.
If you can identify an exclusive jQuery selector (combination) for the whole group of html content, just register the script separately (outside of the block being replaced).