Answer the question
In order to leave comments, you need to log in
How to remove a block by clicking on a link inside it?
In the view, a list of records is generated by the CListView widget:
<? $this->widget('zii.widgets.CListView', array(
'dataProvider'=>$dataProvider,
'itemView'=>'_view',
'ajaxUpdate'=>false,
'template'=>"{items}"
));
<div class="something">
<b><?= $data->username ?></b><br>
<?= $data->email ?>
<a href="#" id="deleteSomething">Delete</a>
<input id="_id" style="display: none;" value="<?= $data->id?>">
</div>
<hr>
Answer the question
In order to leave comments, you need to log in
nothing complicated, in the div add a hidden field with the id record at the link, make the class better. cannot be found by id when there are many records. on click (through on) you hang ajax, and in ajax complete you call update $.fn.yiiListView.update("id-list"); and the list will be updated
$(body),on("click",".deleteSomething",function(){
$.ajax({
url: "htt://site.ru/delete",
data:{"id":$(this).closest(".something").find(".id").val()}
})
.done(function( data ) {
$(this).closest(".something").remove();
$.fn.yiiListView.update("id-list");
});
})
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question