在我的网络应用程序中,我在索引操作 View 中使用 GridView 。我需要创建一个名为“book”的按钮,单击该按钮会显示一个显示相关内容的对话框。 我试过这段代码,但它没有对事件使用react。 我的 index.php GridView 代码
<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!')"
),
),
),
),
));
?>
刷新页面时会显示,但我想在单击按钮时对事件使用react,任何人都可以帮助我解决此问题
最佳答案
您可以为此使用选项:
'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',
),
)
关于javascript - 在 yii 中为 GridView 的点击事件创建警报按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21835520/