Ajax rebind question

I’m having troubles to get working captify plugin in CListView.

Default load of page is OK, captify is working. However when ajax pagination is called, captify stops working because it needs to be rebound on pager links.

This is my solution, which is not working unless I specify alert before rebind:


<?php

Yii::app()->clientScript->registerScript('initVideoList',<<<EOD

	$('.yiiPager a').live('click', function() {

		alert('try captify now'); // <-- without this line rebind is not working

		$('img.captify').captify({}); // rebind

	});

	$('img.captify').captify({}); // this is for default page load (not for ajax)

EOD

, CClientScript::POS_READY);

?>

I suspect its going to be a silly mistake, but anyone could shed a light on this behavior? It is driving me crazy…

Seems like you call captify too soon, and the images are not yet refreshed… you can solve this by using setTimeout() to execute captify after the specified time…

Thank you! This piece of code helped:


$('.yiiPager a').live('click', function() {

		setTimeout(function() {

			$('img.captify').captify({});

		}, 400);

	});

While this not:


$('.yiiPager a').live('click', function() {

		$('img.captify').delay(400).queue(function() {

			$(this).captify({});

		});

	});

Am I missing something there? I cant use delay the way Im using setTimeout?

As the documentation for delay() say - http://api.jquery.com/delay/

[b]

[/b]