【问题标题】:creating alert buttons on click event for grid view in yii在 yii 中为网格视图的单击事件创建警报按钮
【发布时间】:2014-02-17 17:27:42
【问题描述】:

在我的 Web 应用程序中,我在索引操作视图中使用网格视图。我需要创建一个名为“book”的按钮,单击该按钮会显示一个显示相关内容的对话框。 我尝试了这段代码,但它对事件没有反应。 我的 index.php 网格视图代码

<h1>Producer Offers</h1>

<?php 
$this->widget('bootstrap.widgets.TbGridView',array(
    'dataProvider'=>$dataProvider,
        'columns'=>array(


                'offered_vegetable',
                'offered_qty',
                'unit_cost',
                'unit_delivery_cost',

                array(
                    'class'=>"bootstrap.widgets.TbButtonColumn",
                        'deleteConfirmation'=>"js:'Do you really want to delete record with Offer name '+$(this).parent().parent().children(':nth-child(2)').text()+'?'",
                    'template'=>'{view}{book}{delete}',
                    'buttons' =>array(
                            'book'=>
                               array(
                               'label'=>'book',
                               'click' =>"js:alert('do u want to book this offer!')" 


                ),
        ),
                        ),
                ),

        )); 
?>

刷新页面时会显示,但我想在单击按钮时对事件做出反应,有人帮我解决这个问题

【问题讨论】:

  • 控制台有什么错误吗?
  • 不,它没有在控制台中显示错误
  • 你试过用单引号代替双引号吗? 'class'=>"bootstrap.widgets.TbButtonColumn", and 'click' =>"js:alert('do u want to book this offer!')"
  • 你必须使用' 而不是"

标签: javascript php jquery yii


【解决方案1】:

您可以为此使用选项

'book'=> array(
    'label'=>'book',
    'options' => array(  // set all kind of html options in here
        'onclick' =>"js:alert('do u want to book this offer!')",
         'style' => 'font-weight: bold',
    ),
 )

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-12-23
    • 1970-01-01
    • 2022-12-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-05
    相关资源
    最近更新 更多