[Solve] i can't ajax Update/delete model with CJuiDialog (works in CGridView)

i’m newbie yii, i use yii blog applicion

and i install extension updatedialog.

PostContonller


public function actionDelete()

	{

		  $model = $this->loadModel();

		  if( Yii::app()->request->isAjaxRequest )

		  {

		    // Stop jQuery from re-initialization

		    Yii::app()->clientScript->scriptMap['jquery.js'] = false;

		 

		    if( isset( $_POST['action'] ) && $_POST['action'] == 'confirmDelete' )

		    {

		      $model->delete();

		      echo CJSON::encode( array(

		        'status' => 'success',

		        'content' => 'Deleted succussfully',

		      ));

		      exit;

		    }

		    else if( isset( $_POST['action'] ) )

		    {

		      echo CJSON::encode( array(

		        'status' => 'canceled',

		        'content' => 'Deletion canceled',

		      ));

		      exit;

		    }

		    else

		    {

		      echo CJSON::encode( array(

		        'status' => 'failure',

		        'content' => $this->renderPartial( 'delete', array(

		        'model' => $model ), true, true ),

		      ));

		      exit;

		    }

		  }

		  else

		  {

		    if( isset( $_POST['confirmDelete'] ) )

		    {

		      $model->delete();

		      $this->redirect( array( 'admin' ) );

		    }

		    else if( isset( $_POST['denyDelete'] ) )

		      $this->redirect( array( 'view', 'id' => $model->id ) );

		    else

		      $this->render( 'delete', array( 'model' => $model ) );

		  }

	}

view post/admin.php





<?php

<?php $this->widget( 'ext.EUpdateDialog.EUpdateDialog' ); ?>

<?php

$this->breadcrumbs=array(

	'Manage Posts',

);

?>

<h1>Manage Posts</h1>


<?php $this->widget('zii.widgets.grid.CGridView', array(

	'dataProvider'=>$model->search(),

	'filter'=>$model,

	'columns'=>array(

		array(

			'name'=>'title',

			'type'=>'raw',

			'value'=>'CHtml::link(CHtml::encode($data->title), $data->url)'

		),

		array(

			'name'=>'status',

			'value'=>'Lookup::item("PostStatus",$data->status)',

			'filter'=>Lookup::items('PostStatus'),

		),

		array(

			'name'=>'create_time',

			'type'=>'datetime',

			'filter'=>false,

		),

		array(

			'class' => 'CButtonColumn',

		   'deleteButtonUrl' => 'Yii::app()->createUrl( "post/delete", array( "id" => $data->primaryKey ) )',

		    'buttons' => array(

		    	'delete' => array(

		    			'click' => 'updateDialogDelete',),

		    	'update' => array(

		         		'click' => 'updateDialogUpdate',),

		      ),

		),

	),

)); ?>




view post/view.php


<?php $this->widget( 'ext.EUpdateDialog.EUpdateDialog', array(

  'height' => 200,

  'resizable' => true,

  'width' => 300,

)); ?>


<?php

$this->breadcrumbs=array(

	$model->title,

);

$this->pageTitle=$model->title;

?>


<?php $this->renderPartial('_view', array(

	'data'=>$model,

)); ?>


<div id="comments">

	<?php if($model->commentCount>=1): ?>

		<h3>

			<?php echo $model->commentCount>1 ? $model->commentCount . ' comments' : 'One comment'; ?>

		</h3>


		<?php $this->renderPartial('_comments',array(

			'post'=>$model,

			'comments'=>$model->comments,

		)); ?>

	<?php endif; ?>


	<h3>Leave a Comment</h3>


	<?php if(Yii::app()->user->hasFlash('commentSubmitted')): ?>

		<div class="flash-success">

			<?php echo Yii::app()->user->getFlash('commentSubmitted'); ?>

		</div>

	<?php else: ?>

		<?php $this->renderPartial('/comment/_form',array(

			'model'=>$comment,

		)); ?>

	<?php endif; ?>


</div><!-- comments -->



Plzzz i want code Update/delete model with CJuiDialog (works in CGridView).

Hi,

You have the extension installed incorrectly (or giving the path incorrectly), when you extract the archive it folders action/eupdatedialog/example-files, from those folders eupdatedialog folder contains the extension other files are the noise. Sorry it might get a little bit confusing, but because I had to add also non-extension files which is what happened.

sorry you, I was confused. you help me edit code ,plase .

this is code.

http://www.mediafire.com/?n4654yi35ew73nc

thank you.

Sorry I don’t have time for that. Thought through a quick look through your code here is a few pointers:

  • Don’t add extension to main config

  • In extensions move EUpdateDialog folder one level up (EUpdateDialog.php and assets folder should be there ‘example-files’ are currently residing)

  • Don’t dublicate actions and make sure they have access rules to allow