douyou1857 2013-07-17 04:43
浏览 27
已采纳

Yii T ButtonGroup无效

    <?php $this->widget('bootstrap.widgets.TbButtonGroup', array(
    'type'=>'success', 
    'buttons'=>array(
        array('label'=>'Action', 'url'=>'#'),
        array('items'=>array(
            array(
                'label'=>'set approved',
                'url'=>$this->createUrl('controller/dostuff'),
                'buttonType'=>'ajaxButton',
                'ajaxOptions'=>array(
                      'beforeSend' => 'function( request ) {
                          alert(request);
                        }'
                      ,
                      'success' => 'function( data ) {
                          alert(data);
                        }'
                      ,
                  ),
            ),
            array('label'=>'set blocked', 'url'=>'#', 'buttonType' => 'ajaxLink'),
            array('label'=>'set pending', 'url'=>'#', 'buttonType' => 'ajaxLink'),

        )),
    ),
)); ?>

I tried a lot but I cannot get this working.. I want to use yiis ajax behaviour on the first button of the buttongroup.. I dont even get javascript errors or anything.. just if I click the link it redirects me to the url - no ajax at all. Maybe you have an idea

  • 写回答

1条回答 默认 最新

  • douchunji1885 2013-07-17 07:00
    关注

    I see in the TbButton file, see run() method:

    public function run()
    {
        echo $this->createButton();
    
        if ($this->hasDropdown())
        {
            $this->controller->widget('bootstrap.widgets.TbDropdown', array(
                'encodeLabel'=>$this->encodeLabel,
                'items'=>$this->items,
                'htmlOptions'=>$this->dropdownOptions,
            ));
        }
    }
    

    If the button contained in items, it will instance of TbDropdown, not TbButton; So buttonType and ajaxOption you tried to provide are useless.

    You can choose another solution to replace this solution. You can set id for each item and write javascript to do ajax manualy.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部