vasireddy
(Kiranvasi)
August 22, 2011, 10:26pm
1
Dear All ,
This may be a silly question , but couldn’t find solution …
In the below code is there any way to move the dialog part ( I mean from the begin widths to end widget ) to move to some other view file ( may be _mydialog.php) and loading it only when the link is clicked . (Currently the below is code in single view file)
$this->beginWidget('zii.widgets.jui.CJuiDialog', array(
'id'=>'mydialog',
'options'=>array(
'title'=>'Dialog box 1',
'autoOpen'=>false,
'modal'=>true,
),
));
echo 'dialog content here';
$this->endWidget('zii.widgets.jui.CJuiDialog');
echo CHtml::link('open dialog', '#', array(
'onclick'=>'$("#mydialog").dialog("open"); return false;',
));
Thanks for your help
Regards
Yii recent fan
vasireddy
(Kiranvasi)
August 23, 2011, 2:25pm
2
any one
I want to keep it separate because I have around 5 dialogues with fields and every thing in the same view php and loading them always
Wartex
(Wartex)
August 23, 2011, 6:26pm
3
u must always render your dialog widget… if i understand correctly u always wanna use the same dialog. then u can create:
_mydialog.php
$this->beginWidget('zii.widgets.jui.CJuiDialog', array(
'id'=>'mydialog',
'options'=>array(
'title'=>'Dialog box 1',
'autoOpen'=>false,
'modal'=>true,
),
));
echo 'dialog content here';
$this->endWidget('zii.widgets.jui.CJuiDialog');
and in your view dialog.php:
$this->renderPartial('_mydialog.php');
echo CHtml::link('open dialog', '#', array(
'onclick'=>'$("#mydialog").dialog("open"); return false;',
));
of course u can send content text as parameter.
vasireddy
(Kiranvasi)
August 23, 2011, 7:03pm
4
Thank You Wartex .
Unfortunately all my dialog windows are different and they have input fileds . I worked on it and came up with the below solution .
Please let me know if you get any other ideas
//In controller
public function actionOpenDialog1()
{
$data = array();
$this->renderPartial('_dialogContent1', $data, false, true);
}
public function actionOpenDialog2()
{
$data = array();
$this->renderPartial('_dialogContent2', $data, false, true);
}
//In index.view
<div id="data">
</div>
<?php
echo CHtml::ajaxButton ("Open first dialog", CController::createUrl('dialogTesting/openDialog1'),array('update' => '#data'));
echo CHtml::ajaxButton ("Open second dialog", CController::createUrl('dialogTesting/openDialog2'),array('update' => '#data'));
?>
//_dialogContent1.php
<?php
$this->beginWidget('zii.widgets.jui.CJuiDialog', array(
'id'=>'mydialog1',
'options'=>array(
'title'=>'Dialog box 1',
'autoOpen'=>true,
'modal'=>true,
),
));
echo 'first dialog content here';
$this->endWidget('zii.widgets.jui.CJuiDialog');
?>
//_dialogContent2.php
<?php
$this->beginWidget('zii.widgets.jui.CJuiDialog', array(
'id'=>'mydialog1',
'options'=>array(
'title'=>'Dialog box 1',
'autoOpen'=>true,
'modal'=>true,
),
));
echo 'first dialog content here';
$this->endWidget('zii.widgets.jui.CJuiDialog');
?>