Yii Framework Forum: [SOLVED] Highslide and Fancybox not working in CGridview if Page > 1 - Yii Framework Forum

Jump to content

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

[SOLVED] Highslide and Fancybox not working in CGridview if Page > 1 Rate Topic: -----

#1 User is offline   sbasuki 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 40
  • Joined: 14-January 10

Posted 22 March 2011 - 01:03 AM

Highslide and fancybox extension working well on page 1, but not working on the next page (2,3,...)
	$this->widget('zii.widgets.grid.CGridView', array(
		'id'=>'loc-grid',
		'dataProvider'=>$model->search(),
		'filter'=>$model,
			array(
				'header'=>'No.',
				'value'=>'$this->grid->dataProvider->pagination->currentPage*$this->grid->dataProvider->pagination->pageSize + $row+1',       //  row is zero based
				'htmlOptions'=>array('width'=>'25','style'=>'text-align:right;'),
			),
			array('name'=>'loc_picture',
				'type'=>'html',
				'header'=>'Picture',
				'value'=> 'CHtml::link(CHtml::image(Yii::app()->request->baseUrl.$data->loc_picture, "image", array("width"=>30)), Yii::app()->request->baseUrl.$data->loc_picture, array("class"=>"highslide"))',
				'htmlOptions'=>array('width'=>'40','style'=>'text-align:center;'),
			),
			array('name'=>'loc_picture',
				'type'=>'raw',
				'header'=>'Picture',
				'value'=> 'CHtml::link(CHtml::image(Yii::app()->request->baseUrl.$data->loc_picture, "image", array("width"=>30)), Yii::app()->request->baseUrl.$data->loc_picture, array("rel"=>"myrel"))',
				'htmlOptions'=>array('width'=>'40','style'=>'text-align:center;'),
			),
		),
	)); 

$this->widget('application.extensions.fancybox.EFancyBox', array(
	'target'=>'a[rel="myrel"]',
	'config'=>array(
  	'scrolling' => 'yes',
    'titleShow' => true,
		),
	)
);


Any sugestion??
0

#2 User is offline   Antonio Ramirez 

  • Elite Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 1,434
  • Joined: 04-October 10

Posted 22 March 2011 - 03:48 AM

Is the CGridView Ajax updated? That maybe the cause... in order to avoid that, use delegate or live function of jquery in order to make the fancybox to work through AJAX modified contents (you will have to modify the extension.
¿How long would it take for you to understand that you own nothing in this world?

www.ramirezcobos.com


Posted Image
0

#3 User is offline   sbasuki 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 40
  • Joined: 14-January 10

Posted 22 March 2011 - 04:08 AM

View PostAntonio Ramirez, on 22 March 2011 - 03:48 AM, said:

Is the CGridView Ajax updated? That maybe the cause... in order to avoid that, use delegate or live function of jquery in order to make the fancybox to work through AJAX modified contents (you will have to modify the extension.


Sorry, still not understand,
Yes paging in my CGridView using AJAX (default)

so I have to modified fancybox extension??
0

#4 User is offline   sbasuki 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 40
  • Joined: 14-January 10

Posted 22 March 2011 - 08:27 AM

View Postsbasuki, on 22 March 2011 - 04:08 AM, said:

Sorry, still not understand,
Yes paging in my CGridView using AJAX (default)

so I have to modified fancybox extension??


Solve my problem
in CGridView add :
		'afterAjaxUpdate'=>"function(id,data){ $('a[rel=myrel]').fancybox(); }",

2

#5 User is offline   Antonio Ramirez 

  • Elite Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 1,434
  • Joined: 04-October 10

Posted 22 March 2011 - 11:45 AM

Great... I normally use livequery plugin for that so I do not need to worry about calling functions again after AJAX updates. Your solution is good. Thanks for sharing.

With livequery on your main script:
$('a[rel=myrel]') 
    .livequery(function(){ 
    // use the helper function hover to bind a mouseover and mouseout event 
        $(this).fancybox();
    }); 

¿How long would it take for you to understand that you own nothing in this world?

www.ramirezcobos.com


Posted Image
0

#6 User is offline   sbasuki 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 40
  • Joined: 14-January 10

Posted 22 March 2011 - 08:43 PM

View PostAntonio Ramirez, on 22 March 2011 - 11:45 AM, said:

Great... I normally use livequery plugin for that so I do not need to worry about calling functions again after AJAX updates. Your solution is good. Thanks for sharing.

With livequery on your main script:
$('a[rel=myrel]') 
    .livequery(function(){ 
    // use the helper function hover to bind a mouseover and mouseout event 
        $(this).fancybox();
    }); 



Thanks for sharing too.. :)
0

#7 User is offline   sunnycoolboy 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 15-January 11

Posted 13 July 2011 - 08:00 PM

View Postsbasuki, on 22 March 2011 - 08:27 AM, said:

Solve my problem
in CGridView add :
		'afterAjaxUpdate'=>"function(id,data){ $('a[rel=myrel]').fancybox(); }",


Thank you very much!!!
0

#8 User is offline   riyazMuhammed 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 41
  • Joined: 13-September 12
  • Location:Bangalore

Posted 04 November 2012 - 12:51 PM

View Postsbasuki, on 22 March 2011 - 08:27 AM, said:

Solve my problem
in CGridView add :
		'afterAjaxUpdate'=>"function(id,data){ $('a[rel=myrel]').fancybox(); }",



Thanks for the simplest tip !!!
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