使用yiibooster模式小部件,如果用户点击确定确认,我希望它转到其他网址。
$this->widget('bootstrap.widgets.TbButton', array(
'label'=>'Restart Game',
'type'=>'warning',
'htmlOptions'=>array(
'onclick'=>'js:bootbox.confirm("Are you sure?",
function(confirmed){console.log("Confirmed: "+confirmed);})'
),
));
//this is the url i want it to go to when ok confirmed is clicking
'url' =>array('site/restart?gameId='.$gameRecord->id)
答案 0 :(得分:0)
应该是这样的:
'url'=>array('site/restart', array('id'=>$gameRecord->id))
确定您在配置中有或者需要规则吗?
答案 1 :(得分:0)
试试这段代码:
$url = Yii::app()->createAbsoluteUrl('site/restart', array('id'=>$gameRecord->id));
$this->widget('bootstrap.widgets.TbButton', array(
'label'=>'Restart Game',
'type'=>'warning',
'htmlOptions'=>array(
'onclick'=>'js:bootbox.confirm("Are you sure?",
function(confirmed){
if(confirmed) {
window.location = "'.$url.'";
}
})'
),
));