ajaxLink ajaxButton side effect

Hi got some side effect with ajaxLink and ajaxButton

so just a example


  <?php echo CHtml::ajaxLink("Click Me",


		  array('update' => '#update', 'type' => 'GET')); ?>




<div id="update">




so what happend everything fine link will call view next

ok in view next follow

  <?php echo CHtml::ajaxLink("Click Me 2",


		  array('update' => '#update', 'type' => 'GET')); ?>

<div id="update">




view next2

  <?php echo CHtml::ajaxLink("Click Me 3",


		  array('update' => '#update', 'type' => 'GET')); ?>

so what happen the first time it works but if i click "Click Me 2"

ajax Link will call next and next 2 .

and if i Click "Click Me 3" the will call next, next2 and next 3

This is a complex issue and I think we will have to look forward for a generic solution.

You can search the forum and you will find several threads about this and related issues (have a look in the bug tracker too).

Here’s an attempt for just a rough explanation:

On initial load, 1st ajax update, 2nd ajax update, and so on, elements are generated with id’s like yt0, yt1, …

The numbering in each update is independent of the others so id collisions will occur.

Depending on if the fourth parameter to renderPartial is true, additional jQuery stubs will be inserted into the document. For element id’s not initially present, the fourth parameter to renderPartial would be needed in order for a event handler to be attached to the newly inserted element. But for resident element id’s the document (may?) end up with several handlers attached to the same element id (originally attached to content that is no longer present).

If I got it correctly, without the fourth parameter to renderPartial, elements originally present and replaced with same id’s should automatically have the events rearmed by the jQuery.live() functionality. However it seems like this not always(/ever?) work.

If you didn’t already try, check what happens if you leave out the fourth parameter to renderPartial.

Otherwise I think you should be able to work around the issue by giving all elements unique id’s. E.g:


  echo CHtml::ajaxLink(

    "Click Me 3",


    array('update' => '#update', 'type' => 'GET'),

    array('id' => 'some_unique_id')

); ?>


yee i think that with the id is a good solution.

thanx a lot