Yii Framework Forum: Ajax Problem - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Ajax Problem Rate Topic: -----

#1 User is offline   mbala 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 155
  • Joined: 21-July 12
  • Location:Chennai, Tamilnadu, India

Posted 04 December 2012 - 07:02 AM

Yii::app()->clientScript->registerScript('subdeletejs', "
$('.sdelete').click(function(){
alert('hai');
});

");
<?php $this->widget('zii.widgets.grid.CGridView', array(
.....
....
'columns'=>array(
       name,
      array(
	 'class'=>'CButtonColumn',
         'template'=>'{view}{update}{deletethis}',
         'buttons'=>array(
               'deletethis'=>array(
                    'imageUrl'=>Yii::app()->baseUrl.'/images/delete.png',
                    'options'=>array('class'=>'sdelete'),
                ),
            ),
	  ),
),
)); ?>

This is sample code of my work format.
This code was working fine, When page load. When i use ajax update for gridview, it is not work. No error No output.
What i do ?
0

#2 User is offline   luc 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 211
  • Joined: 22-June 10
  • Location:france

Posted 04 December 2012 - 07:28 AM

'columns'=>array(
       name,


should be:

'columns'=>array(
       'name',

Hey Ho !
Let's go !
0

#3 User is offline   CeBe 

  • Advanced Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 480
  • Joined: 16-July 10
  • Location:Berlin. Germany

Posted 04 December 2012 - 08:06 AM

When you reload elements with ajax event binding get removed. You have to add that js code to after update event of gridview that it runs after content has been updated and assigns event bindings to the new loaded elements.
0

#4 User is offline   mbala 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 155
  • Joined: 21-July 12
  • Location:Chennai, Tamilnadu, India

Posted 04 December 2012 - 08:06 AM

I gave only sample format of my code. Everything working fine on page load. But registerScript not work on cgridview ajax page navigation
0

#5 User is offline   CeBe 

  • Advanced Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 480
  • Joined: 16-July 10
  • Location:Berlin. Germany

Posted 04 December 2012 - 08:18 AM

Have you read my post, mbala?
0

#6 User is offline   mbala 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 155
  • Joined: 21-July 12
  • Location:Chennai, Tamilnadu, India

Posted 04 December 2012 - 08:56 AM

View PostCeBe, on 04 December 2012 - 08:18 AM, said:

Have you read my post, mbala?

Thanks CIBI. I got solution
Yii::app()->clientScript->registerScript('subdeletejs', "
$('.sdelete').click(function(){
alert('hai');
});

");
<?php $this->widget('zii.widgets.grid.CGridView', array(
.....
....
'columns'=>array(
       name,
      array(
         'class'=>'CButtonColumn',
         'template'=>'{view}{update}{deletethis}',
         'buttons'=>array(
               'deletethis'=>array(
                    'imageUrl'=>Yii::app()->baseUrl.'/images/delete.png',
                    'options'=>array('class'=>'sdelete'),
                ),
            ),
          ),
),
'afterAjaxUpdate'=>'function() {
  alert("Thank You");
}
)); ?>


It is working fine after every update of cgridview
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users