eupdatedialog - issue delete button

Hello everyone,

I tried to install the extension eupdatedialog and I have a problem. Using "action files" that I placed in the folder Components / action.

I add the following code to my grid view




array (

'class' => 'CButtonColumn',

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

       'buttons' => array (

         'delete' => array (

           'clicks' => 'updateDialogDelete',

         )

         'update' => array (

           'clicks' => 'updateDialogUpdate',

         ))

        

)



The edit button works correctly. Open the edit form in a dialog. The delete button behave as if I had not used the extension. It asks me if I want to delete the record, not by displaying the view "delete" that I created according to the instructions in the documentation of the extension. When I press the record I want to delete the operation fails because the action is expected to receive a post parameter (one of the buttons in view "delete").

I thought that I must replace all of the delete button and put a csutom. But it does not seem like very logical thing.

What can I do??

I have the same problem with the link created

echo "<a href=\"create\" class=\"create\">CREA</a>";

I solved the first problem. Coferma mean the message that you get automatically when you delete a record. Is there a property to set

‘deleteConfirmation’ => false,

Now step to the other two

Sorry you are having problems with my extension.

I see some errors in posts code (‘clicks’ rather than ‘click’, ‘date’ rather than ‘data’), maybe it’s just copy-paste bug but thouth I menthion that.

You might have some problems with ‘deleteConfirmation’ property set to true, because then Yii adds its own JavaScript, but because ‘click’ property is set Yii shouldn’t pay attention to this property Yii Docs.

As for the model creatio you should use CHtml::link, so this link use the right url.




  <?php echo CHtml::link( 'Add new location', array( 'create' ), array( 

    'class' => 'update-dialog-create' ) ); ?>



Also if you use different class for create link other than default, you need to update eUpdateDialog.js file. Change default class with your own inside jQuery selector. This is the code you need to modify:




jQuery( function($){

  $( 'a.update-dialog-create' ).bind( 'click', updateDialogCreate );

});



I would also suggest to get FireBug add-on for your browser. It’s a real lifesaver, because you can track your code (check that link it uses when you press, which parameters are send, view server response).

If you are still having problems, send me code if you can (extension if you modified it, admin or other view file which uses the extension). Hope this helps :)

Thanks for the reply.

The first error you reported is obviously a mistake copy - paste.

The error was the name of the class that I used. Inserted only as a class "dialog" instead of "update-dialog-created."

Now almost everything works fine.

The problem is always the delete button. If I press the first time everything is ok., If I press a second time nothing happens. Under the code of my grid. The extension has not been modified.




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

	'id'=>'test-table-grid',

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

	'filter'=>$model,

	'columns'=>array(

		'id',

		'descrizione',

		array(

			'class'=>'CButtonColumn',

      'template'=>'{delete}{update}',

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

      'deleteConfirmation'=>true,

      'buttons' => array(

        'delete' => array(

          'click' => 'updateDialogDelete',

          'options'=>array('class'=>'update-dialog-create')    

         

        ),

        'update' => array(

          'click' => 'updateDialogUpdate',

        ),

         

        ),  

        

		),

	),

)); 



I used such a long class name so it would easily be know what it is used by extension and for which action, and to avoid class collisions.

For starters you should remove


'deleteConfirmation' => true

or set it to false, because you are using a view for delete confirmation. Otherwise Yii might decide to add extra code to show delete confirmation through JavaScript, which might break extension and default Yii deletion through JavaScript will stop working without JavaScript.

Second, you don’t need to use a class for delete or update button which are inside grid view (plus you are using wrong class). You need that class for create model links for jQuery so it can attach click events to them.

So in short:

  • Remove or set ‘deleteConfirmation’ to false (just in case)

  • Update and delete buttons which are in grid view only needs ‘click’ property set

  • Model action links which are not in grid view needs a class for jQuery to set the click event

I haven’t tested this but it should be possible to use update/delete model with links which aren’t inside grid view (only data refresh won’t work, as I only implemented that for grid view for now). In example (not tested), links can be created like:




<?php echo CHtml::link( 'Add new location', array( 'create' ), array( 

  'class' => 'update-dialog-create' ) ); ?>

<?php echo CHtml::link( 'Update location', array( 'update' ), array( 

  'class' => 'update-dialog-update' ) ); ?>

<?php echo CHtml::link( 'Delete location', array( 'delete' ), array( 

  'class' => 'update-dialog-delete' ) ); ?>



You can use different classes for links, but remember that you will need to update eUpdateDialog.js to use those classes for selector.

And then you will need to update eUpdateDialog.js file with this code (I added here the create code, but it is already inside extensions JavaScript file, so you need only add code for update and delete):




jQuery( function($){

  $( 'a.update-dialog-create' ).bind( 'click', updateDialogCreate );

});

jQuery( function($){

  $( 'a.update-dialog-update' ).bind( 'click', updateDialogUpdate );

});

jQuery( function($){

  $( 'a.update-dialog-delete' ).bind( 'click', updateDialogDelete );

});



If it still not working like it should, try to use http://getfirebug.com/ add-on. Just enable NET panel and using console panel just that is being requested and send.

I’m attaching one of my admin view files which uses this extension, so you can compare it with yours to help you out.

mmm don’t work

this is the code of my admin file

I had already changed the properties deleteConfirmation.

I had alredy used firebug.

If I remove the class name, from delete grid button , which happens when you press the delete button is a inotrate two requests one to action delete and onother to action admin. The dialog does not appear.

What I forget?








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

$this->breadcrumbs = array(

    'Test Tables' => array('index'),

    'Manage',

);


$this->menu = array(

    array('label' => 'List TestTable', 'url' => array('index')),

    array('label' => 'Create TestTable', 'url' => array('create')),

);




Yii::app()->clientScript->registerScript('search', "

$('.search-button').click(function(){

	$('.search-form').toggle();

	return false;

});

$('.search-form form').submit(function(){

	$.fn.yiiGridView.update('test-table-grid', {

		data: $(this).serialize()

	});

	return false;

});

");

?>


<h1>Manage Test Tables</h1>


<p>

  You may optionally enter a comparison operator (<b>&lt;</b>, <b>&lt;=</b>, <b>&gt;</b>, <b>&gt;=</b>, <b>&lt;&gt;</b>

  or <b>=</b>) at the beginning of each of your search values to specify how the comparison should be done.

</p>







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

    'id' => 'test-table-grid',

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

    'filter' => $model,

    'columns' => array(

        'id',

        'descrizione',

        array(

            'class' => 'CButtonColumn',

            'template' => '{delete}{update}',

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

            'deleteConfirmation' => false,

            'buttons' => array(

                'delete' => array(

                    'click' => 'updateDialogDelete',

                ),

                'update' => array(

                    'click' => 'updateDialogUpdate',

                ),

            ),

        ),

    ),

));






I will try to use your admin view with my own project and let you know how it goes.

Also have you updated your loadModel or action methods as described in Gii code generator ?

<?php tag missing before grid view widget. copy-paste error?

So I tried your code, replacing only deleteButtonUrl to lead to one of my models, and replacing descrizione attribute with one of my models attributes and it works perfectly. I also disabled my custom client script extension and it still works perfectly.

I’m attaching my own controller. But now as I’m looking at the controller code I see think that you might be missing private $_model property.

Yes

Yes

don’t work

Well then, I actually have no idea that is wrong, because it should work.

Maybe you can send me a zip archive containing the model, controller, all view files for the model, and a screenshot of firebug net panel after you click the delete button. If I look at all the code maybe I will be able to spot the problem.

A fantastic plugin that saves lots of my time but wonder how can we achieve multiple record delete with it.?? i am struggling with it… can anybody help me with this?

Thanks,

jack

I love the concept of this extension. The problem that I have is that I need to use it in an autocomplete to create a new record and I can’t figure out how to do it. I basically have all of the results being returned to the user from the autocomplete with “Add New Item” being the last result. I would like the dialog to open when the user clicks “Add New Item”. Any suggestions?

Thanks for this extension. It is working great for me but now I find I need the returned data in my custom javascript callback so I can update a dropdownlist. Is there a way to access it without changing EupdateDialog.js to pass data instead of data.status into the callbacks?