Hi all:
This may be more of a JavaScript issue rather than Yii, but I’m baffled and would appreciate some help. I have a TbListView where I want to show an onclick dialog containing an attribute that is part of the row but not shown in the list. I reckon this approach is simpler than using Ajax calls because TbListView has already retrieved all the data so there’s no need to go back to the server.
View show.php:
<?php $this->widget('bootstrap.widgets.TbListView',array(
	'dataProvider'=>$dataProvider,
	'itemView'=>'_show',
	'summaryText' => '',
	'template' => '{items}',
	'enableHistory' => false,
	'enablePagination' => false,
	'separator' => '',
	'cssFile' => false,
)); ?>
<?php $this->beginWidget('zii.widgets.jui.CJuiDialog', array(
	'id' => 'plan-dialog',
	'options' => array(
		'autoOpen' => false,
		'width' => 450,
		),
	));
?>
<div class="plandesc"></div>
<?php $this->endWidget(); ?>
itemView _show.php:
<div class="view">
<div class="table table-condensed table-hover">
    <table>
        <tbody>
            <tr>
                <th>
                    <b><?php echo CHtml::encode($data->getAttributeLabel('plan_code')); ?></b>
                </th>
                <td>
                    <?php echo CHtml::link(CHtml::encode($data->plan_code),'#',array(
                        'onclick'=>'{
                            $("#plan-dialog").
                            dialog({title: "' . $data->plan_code . ' Plan Description"}). // <- THIS WORKS!
                            html("' . $data->description . '"). // <- THIS DOES NOT WORK!
                            dialog("open");
                            return false;
                            }'
                         ));
                    ?>
                </td>
            </tr>
            <tr>
                <th>
                    <b><?php echo CHtml::encode($data->getAttributeLabel('title')); ?></b>
                </th>
                <td>
                    <?php echo CHtml::encode($data->title); ?>
                </td>
            </tr>
            <tr>
                <th>
                    <b><?php echo CHtml::encode($data->getAttributeLabel('price')); ?></b>
                </th>
                <td>
                    <?php echo CHtml::encode($data->price); ?>
                </td>
            </tr>
        </tbody>
</table>
</div>
</div>
The $data->plan_code is a simple string while the $data->description attribute contains HTML composed with the redactor editor.
The dialog doesn’t display at all when I click on the link but if I replace the $data->description attribute with simple text it is displayed in the dialog body fine. I’m puzzled because it does work for the dialog title attribute (which comes from $data->plan_code). Perhaps the problem lies with the dialog’s .html method and how it reacts to actual HTML code because if I CHtml::encode it then it displays, albeit with garbage characters.
Any ideas? Thanks in advance.