Hi, friends
I have created a few dialogs in a main layout of view, via chtml::link. My purpose, show the dialog which bind from admin view when users is clicked. the problem is where i can’t bind admin.php view into dialog. please give me the words of advice. thanks in advance.
layout/main.php
<li>
<?php echo CHtml::link('Manage Order', "", // the link for open the dialog
array(
'style'=>'cursor: pointer; text-decoration: none;',
'id'=>'menu_manage_order',
'onclick'=>"{manageOrder();$('#dialogManageOrder').dialog('open'); }"
));
?>
</li>
<?php
$this->beginWidget('zii.widgets.jui.CJuiDialog', array( // the dialog
'id'=>'dialogManageOrder',
'options'=>array(
'title'=>'Manage Order',
'autoOpen'=>false,
'modal'=>true,
'width'=>1200,
'height'=>'auto',
),
));
?>
<div class="divManageOrder"></div>
<?php $this->endWidget();?>
<script type="text/javascript">
function manageOrder()
{
<?php $title='Order';?>
$('#dialogManageOrder').dialog('open');
<?php echo CHtml::ajax(array(
'url'=>array('/order/admin'),
'data'=> "js:$(this).serialize()",
'type'=>'post',
'dataType'=>'json',
'success'=>"function(data)
{
if (data.status == 'failure')
{
$('#dialogManageOrder div.divManageOrder').html(data.div);
// Here is the trick: on submit-> once again this function!
$('#dialogManageOrder div.divManageOrder form').submit(manageOrder);
}
else
{
$('#dialogManageOrder div.divManageOrder').html(data.div);
//setTimeout(\"$('#dialogManageOrder').dialog('close') \",3000);
}
} ",
));
?>
return false;
}
</script>
controller/order.php
public function actionAdmin()
{
if (Yii::app()->request->isAjaxRequest)
{
$model=new Order('search');
$model->unsetAttributes(); // clear any default values
if(isset($_GET['Order']))
$model->attributes=$_GET['Order'];
$this->render('admin',array(
'model'=>$model,
));
Yii::app()->end();
}
}
view/admin.php
<?php
$this->breadcrumbs=array(
'Orders'=>array('index'),
'Manage',
);
$this->menu=array(
array('label'=>'List Order', 'url'=>array('index')),
array('label'=>'Create Order', 'url'=>array('create')),
);
Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
$('.search-form').toggle();
return false;
});
$('.search-form form').submit(function(){
$.fn.yiiGridView.update('order-grid', {
data: $(this).serialize()
});
return false;
});
");
?>
<h1>Manage Orders</h1>
<p>
You may optionally enter a comparison operator (<b><</b>, <b><=</b>, <b>></b>, <b>>=</b>, <b><></b>
or <b>=</b>) at the beginning of each of your search values to specify how the comparison should be done.
</p>
<?php echo CHtml::link('Advanced Search','#',array('class'=>'search-button')); ?>
<div class="search-form" style="display:none">
<?php $this->renderPartial('_search',array(
'model'=>$model,
)); ?>
</div><!-- search-form -->
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'order-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
'order_id',
'customer_id',
'order_status',
'lat',
'lng',
'address',
/*
'received_date',
'completed_date',
'staff_id',
'created_date',
'upated_date',
*/
array(
'class'=>'CButtonColumn',
),
),
)); ?>