But I did not used any jquery.live() method… All the CDATA script above was AUTO generated by yii… My only code was :
array(
'type'=>'raw',
'value'=>'CHtml::ajaxLink(CHtml::image("' . Yii::app()->request->baseUrl . '/images/uparrow.png","up",array("border"=>0)),Yii::app()->createUrl("/product/reposition"),array(
"data"=>array(
"id"=>$data->Id,
"direction"=>"up",
"sortOrder" =>$data->SortOrder,
),
"update"=>"#profileGrid",
))." ".
CHtml::ajaxLink(CHtml::image("' . Yii::app()->request->baseUrl . '/images/downarrow.png","down",array("border"=>0)),Yii::app()->createUrl("/product/reposition"),array(
"data"=>array(
"id"=>$data->Id,
"direction"=>"down",
"sortOrder" =>$data->SortOrder,
),
"update"=>"#profileGrid",
));',
), /*
After I press on the sort button, the grid reload with a new order, but the references to the sort button (yt0,yt1) still refers to the earlier Id.
First time load
Id | Title | Sort Order
38 apple 1 (click down button on this row, controller receive Id as 38, so I can swap the sortorder)
25 banana 2
72 citrus 3
CDATA
jQuery(’#yt0’).live(‘click’,function(){jQuery.ajax({‘data’:{‘id’:‘38’
jQuery(’#yt0’).live(‘click’,function(){jQuery.ajax({‘data’:{‘id’:‘25’
jQuery(’#yt0’).live(‘click’,function(){jQuery.ajax({‘data’:{‘id’:‘72’
After click, the Ajax refreshed (correctly shown on the grid)
Id | Title | Sort Order
25 banana 1 (click down button on this row, controller STILL receive Id as 38, it shud be 25)
38 apple 2
72 citrus 3
I need the yt0, yt1 in the CDATA to follow the new Id order too (25,38,72). Right now when I click on the sort button of 1st row (id=25) the controller receive the id as 38!! (previous sort order)
I am still very new to yii and jquery stuff…