Hi guys
I have a CJuiDialog containing a Gridview that opens fine and works perfectly. I can paginate, filter and all that kind of stuff. However when I click the close button in the dialog title bar and then reopen the dialog, the pagination stops working and invariably firefox crashes so I can’t see the error in the console. I’ve tried all sorts of things such as turning on and off various scriptmaps, setting the processOutput boolean in renderPartial to true/false. The only thing that works reliably is refreshing the page on clicking the close button. This is not ideal as the user may have already filled in some other fields.
So basically I have my view which preloads a CJuiDialog. On clicking the ajaxbutton, the actionShowCourseList is called in the controller and the partial page ‘_courseList’ is rendered in the dialog. It all works fine until I close and then reopen the dialog.
Here is my code. I’ve stripped out all the boilerplate and unnecessary stuff to save space so I hope it makes sense.
<?php $form = $this->beginWidget('CActiveForm', array(
'id' => 'course-period-form',
)); ?>
/*
* Form elements here which I've stripped out the form elements here to save space. They are populated from the dialog
*/
......
<?php
// Button to call dialog
echo CHtml::ajaxButton('Select Course', $this->createUrl('/course/showCourseList',
array(
'course' => $model->isNewRecord ? null : $model->id
)),
array(
"success" => 'function(data){
$("#dialog").dialog("option", "title", "Add Course");
$("#dialog").html(data).dialog("open");
return false;
}',
),
);
?>
</div>
</div>
</fieldset>
</div>
<?php $this->endWidget(); ?>
<!-- CJuiDialog -->
<?php $this->Widget('zii.widgets.jui.CJuiDialog', array(
'id' => 'dialog',
'options' => array(
'title' => 'Show data',
'show' => 'fade',
'autoOpen' => false,
'modal' => true,
'width' => '80%',
'height' => 'auto',
// This is how I'm getting the dialog to work again on reopening
'close' => 'js:function(event, ui) { location.reload(); }'
),
));
// The partial page ('_courseList') to be rendered in the dialog
Yii::app()->clientScript->scriptMap = array(
//scripts that we don't need inside this view
'jquery.js' => false,
'jquery.min.js' => false,
'jquery.maskedinput.min.js' => false,
'jquery-ui.min.js' => false,
);
$this->widget('bootstrap.widgets.TbExtendedGridView', array(
'id' => 'course-grid',
'dataProvider' => $courses->search(),
'type' => 'striped bordered condensed',
'filter' => $courses,
'columns' => array(
array(
'header' => 'ID',
'name' => 'course_id',
'htmlOptions' => array('width' => '40px'),
),
array(
'header' => 'Course Name',
'name' => 'course_name',
),
.... and so on
?>
// The action to show the dialog
public function actionShowCourseList()
{
$courses = new Course('search');
$courses->unsetAttributes();
if (isset($_GET['Course'])) {
$courses->attributes = $_GET['Course'];
}
$this->renderPartial('/course/_courseList',
array('courses' => $courses),
false, false);
Yii::app()->end();
}
Any ideas would be greatly appreciated!