[英]how set callback function in CJuiDialog yii
打開對話框窗口后,我需要通過ajax顯示表單。
$this->beginWidget('zii.widgets.jui.CJuiDialog', array(
'id' => 'register',
'actionPrefix' => 'register',
// additional javascript options for the dialog plugin
'options' => array(
'title' => 'registration',
'autoOpen' => false,
'width' => 800,
'height' => 500,
'buttons' => array(
'showform'=>'js:function(){
$.ajax({
type: "POST",
url : "' .$this->createUrl("/Site/Register"). '"
success:function(data){
$("#form-test").html(data);
}
})}'
),),));
但這不起作用。 如何在CJuiDialog中設置回調函數
試試看..更好JuiDialog單擊登錄按鈕時打開,如:-
<?php
$this->beginWidget('zii.widgets.jui.CJuiDialog', array(
'id' => 'login-dialog',
'options' => array(
'title' => 'View Location',
'autoOpen' => false,
'modal' => true,
'width' => 'auto',
'height' => 'auto',
'resizable' => false,
),
));
$this->endWidget();
echo CHtml::ajaxButton("Login", Yii::app()->createUrl('site/login'), array(
'type' => 'post',
'success' => 'function(r){$("#login-dialog").html(r).dialog("open"); return false;}'
), array('class' => 'search_btn'));
?>
如果您仍然想通過CJuiDialog的按鈕選項訪問它
嘗試:-
<?php
$this->beginWidget('zii.widgets.jui.CJuiDialog', array(
'id' => 'login-dialog',
'options' => array(
'title' => 'View Location',
'autoOpen' => false,
'modal' => true,
'width' => 'auto',
'height' => 'auto',
'resizable' => false,
'buttons' => array(
'showform'=>'js:function(){$.ajax({
type: "post",
url: "'. Yii::app()->createUrl('site/login') .'",
success:function(data){$("#login-dialog").html(data);}
});}',
'Cancel'=>'js:function(){$("#login-dialog").dialog("close");}',),
),
));
$this->endWidget();
echo CHtml::link("Login", '#', array(
'onclick'=>'$("#login-dialog").dialog("open"); return false;',
), array('class' => 'search_btn'));
?>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.