在视图部分,我想检查$ check值是否== true然后打开CJuiDialog
<?php
if($check==true)
{
js:function(){$('#dialogDisplay').dialog('open');}
}
$this->beginWidget('zii.widgets.jui.CJuiDialog', array(// the dialog
'id' => 'dialogDisplay',
'options' => array(
'title' => 'Display Setting',
'autoOpen' => false,
'modal' => true,
'width' => 300,
'height' => 200,
'buttons' => array(
array('text' => 'Submit', 'click' => 'js:function(){ document.myform.submit();}'),
array('text' => 'Cancel', 'click' => 'js:function(){$(this).dialog("close");}')),
),
));
?>
<div class="divForForm">
<form name="myform" action="/dataset/resetPageSize" method="post">
Items per page:
<select name="filePageSize" class="selectPageSize">
<option value="5">5</option>
<option value="10" selected>10</option>
<option value="20">20</option>
<option value="50">50</option>
<option value="100">100</option>
<option value="200">200</option>
</select>
<br>
Size: <input type="checkbox" name="size" checked />
<input type="hidden" name="url" value="<? echo Yii::app()->request->requestUri; ?>" />
</form>
</div>
<?php $this->endWidget(); ?>
但它不起作用,我只是开始学习javascript,我不知道如何在$ check == true时运行它
答案 0 :(得分:1)
您需要将脚本标记打印到客户端:
<?php
// If PHP variable $check is true
if($check == true) {
// Print out jQuery ready function to the client side,
// which will run when the page loads
echo "<script>$(function(){ $('#dialogDisplay').dialog('open'); })</script>";
}