I currently have a CJuiTabs object with multiple tabs, one of which has a couple CJuiButtons that when pressed, will each bring up different CJuiDialogs. I noticed that when I click the tab that contains the dialogs, that multiple divs are created for the dialog objects and if I switch back and forth to other tabs, the number of duplicated dialog div elements increases.
The CJuiTab definition:
$this->widget('zii.widgets.jui.CJuiTabs', array(
'tabs'=>array(
'Profile'=>array('ajax'=>CHtml::normalizeUrl(array('user/profile')), 'id'=>'profile'),
'Groups'=>array('ajax'=>CHtml::normalizeUrl(array('user/groups')), 'id'=>'groups'),
'Contacts'=>array('ajax'=>CHtml::normalizeUrl(array('user/contacts')), 'id'=>'contacts'),
'Settings'=>array('ajax'=>CHtml::normalizeUrl(array('user/settings')), 'id'=>'settings'),
),
));
?>
The ajax call to user/contacts via my controller has the follwing code:
return $this->renderPartial('tab_contacts', array('contactForm'=>$contactForm, 'dataProvider'=>$dataProvider), false, true);
The actual tab contents:
<?php
$this->beginWidget('zii.widgets.jui.CJuiDialog', array(
'id'=>'new_contact_dlg',
'options'=>array(
'title'=>'Add Contact',
'autoOpen'=>false,
'resizable'=>false,
),
));
$this->renderPartial('//user/dlg_new_contact', array('model'=>$contactForm), false, true);
$this->endWidget('zii.widgets.jui.CJuiDialog');
$this->beginWidget('zii.widgets.jui.CJuiDialog', array(
'id'=>'import_contacts_dlg',
'options'=>array(
'title'=>'Import Contacts',
'autoOpen'=>false,
'resizable'=>false,
),
));
$this->renderPartial('//user/dlg_import_contacts', null, false, true);
$this->endWidget('zii.widgets.jui.CJuiDialog');
?>
<div style="text-align: right;">
<?php
$this->widget('zii.widgets.jui.CJuiButton',
array('name'=>"new_contact_button",
'buttonType'=>'button',
'caption'=>'new contact',
'onclick'=>'js:function(){$("#new_contact_dlg").dialog("open");}'
)
);
$this->widget('zii.widgets.jui.CJuiButton',
array('name'=>"import_contacts_button",
'buttonType'=>'button',
'caption'=>'import contacts',
'onclick'=>'js:function(){$("#import_contacts_dlg").dialog("open");}'
)
);
?>
</div>
<?php
$this->widget('zii.widgets.grid.CGridView', array(
'dataProvider'=>$dataProvider,
'columns'=>array(
'full_name',
'email',
array(
'class'=>'CButtonColumn',
'template'=>'{edit}',
'buttons'=>array
(
'edit' => array
(
'label'=>'Edit',
'url'=>'Yii::app()->createUrl("contacts/edit", array("id"=>$data->id))',
),
),
),
array(
'class'=>'CButtonColumn',
'template'=>'{delete}',
'buttons'=>array
(
'delete' => array
(
'label'=>'Delete',
'url'=>'Yii::app()->createUrl("contacts/delete", array("id"=>$data->id))',
),
),
),
),
));
?>
Any ideas on what I may be doing wrong here? Thanks.
-Schlegz