Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8169261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T20:47:26+00:00 2026-06-06T20:47:26+00:00

CGridView widget is already having view,update,dete option.But i am using CListView widget in my

  • 0

CGridView widget is already having view,update,dete option.But i am using CListView widget in my jquery mobile based project, but having problem in creating ajax link for delete option. Not getting idea how to create a ajax delete link in _view.php(view file) and its renderPartial() view file to disappear the bar after successfully deleted plz help thanks in advance. Here is the _view.php file link for edit and delete.

<?php 
echo CHtml::link(CHtml::encode($data->id), 
    array('editmember1', 'id' => $data->id), 
    array('data-role' => 'button', 'data-icon' => 'star')
);

echo CHtml::link(CHtml::encode($data->id), $this->createUrl('customer/delete', array('id' => $data->id)), 
    array(
       // for htmlOptions
       'onclick' => ' {' . CHtml::ajax(array(
       'beforeSend' => 'js:function(){if(confirm("Are you sure you want to delete?"))return true;else return false;}',
       'success' => "js:function(html){ alert('removed'); }")) .
       'return false;}', // returning false prevents the default navigation to another url on a new page 
       'class' => 'delete-icon',
       'id' => 'x' . $data->id)
   );

?>

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T20:47:27+00:00Added an answer on June 6, 2026 at 8:47 pm

    This is happening because:

    1. The correct action is not being called, because you have not set the url property of jQuery.ajax(). You should know that Yii’s CHtml::ajax is built on top of jQuery’s ajax. So you can add :

      CHtml::ajax(array(
        ...
        'url'=>$this->createUrl('customer/delete', array('id' => $data->id,'ajax'=>'delete')),
        ...
      ))
      

      Also in the url i’m passing an ajax parameter so that the action knows that it’s an ajax request explicitly.

    2. Then the controller action by default(i.e Gii generated CRUD) expects the request to be of post type, you can see this in the customer/delete action line:if(Yii::app()->request->isPostRequest){...}. So you have to send a POST request, again modify the ajax options:

      CHtml::ajax(array(
        ...
        'type'=>'POST',
        'url'=>'',// copy from point 1 above
        ...
      ))
      
    3. Alternatively you can also use CHtml::ajaxLink().

    4. To update the CListView after deletion, call $.fn.yiiListView.update("id_of_the_listview");. Something like:

      CHtml::ajax(array(
        ...
        'type'=>'POST',
        'url'=>'',// copy from point 1 above
        'complete'=>'js:function(jqXHR, textStatus){$.fn.yiiListView.update("mylistview");}'
        ...
      ))
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

can some buddy please suggest how to disable view button on cgridview widget and
I use this grid to view a table with data: View part: <?php $this->widget('zii.widgets.grid.CGridView',
I am using CGridView to show data in grid format, but i am not
In my project, i am using cgridview to display some information and using the
I'm using a CGridView on a website to display data provided via a CArrayDataProvider.
I am using CGridView in Yii, how can I display a single record in
In Yii, CGridView has it's own background color in the row. But what I
Hi I have created one fully xml based project. my doubts now I store
The issue I'm having is related to multiple models in a single controller/view in
good day, i am having a bit of a problem here. i am using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.