0

使用 yiibooster 模态小部件,如果用户单击确定确认,我希望它转到不同的 url。

$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)
4

2 回答 2

0

应该是这样的:

'url'=>array('site/restart', array('id'=>$gameRecord->id))

假设您有或需要配置中的规则?

于 2013-07-29T04:09:38.030 回答
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.'";
                }
             })'
        ),
  ));
于 2013-07-29T04:30:21.950 回答