When i want to add a jquery library in order to trunc a long text, the text is trunced very well. But as soon as i sort a column in the CGridView, the text is not trunced anymore (the less and the more link diseappear). Its seems like the javascript file is not recognized when i sort a column.
Here is is my code:
// i register my javascript file as follow:
Yii::app()->clientScript->registerScript(Yii::app()->baseUrl."/scripts/trunc.js");
Yii::app()->clientScript->registerScript('sample1', "
$('.sample1').truncated();
");
$this->widget('zii.widgets.grid.CGridView', array(
'dataProvider'=>$dataProvider,
'columns'=>array(
array(
'name'=>'description',
'value'=>'$data->truncedDescription',
),
array( // display a column with "view", "update" and "delete" buttons
'class'=>'CButtonColumn',
),
),
));
it is not a bug, the problem arises when you do an ajax call the DOM object that you truncate is renewed in the DOC and your $(’.sample1’).truncated(); is not working anymore.
In order to maintain my events within the page I always use .live() -since jquery 1.4.1 you can do custome events.