首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >yii2 Pjax + java脚本提示

yii2 Pjax + java脚本提示
EN

Stack Overflow用户
提问于 2015-06-20 15:06:33
回答 1查看 547关注 0票数 0

有没有办法使'data-confirm' => Please enter the number'不仅确认,而且像JS提示符一样,得到计算值,将其发送给控制器?

代码语言:javascript
复制
 <?php \yii\widgets\Pjax::begin(['id' => 'pjax-orders_table','clientOptions' => ['method' => 'POST'], 'enablePushState'=>false]) ?>
    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'id'=>'orders_table',
        'columns' => [
            ['class' => 'yii\grid\SerialColumn'],
            ///some columns

            [
                'class' => 'yii\grid\ActionColumn',
                'template' => '{update} {delete}{some}',
                'buttons' => [

                    'some' => function ($url,$model,$key) {
                        if($model->status=='not confirm')
                        {
                            return Html::a('<span class="glyphicon glyphicon-trash"</span>',['my/some', 'id' => $model->id],[
                                'title' => Yii::t('yii', 'Delete'),
                                'data-confirm' => Please enter the number',
                                'data-method' => 'post',

                            ]);
                        }

                    },
                ],
            ],
        ],
    ]); ?>
    <?php \yii\widgets\Pjax::end() ?>

在控制器中

代码语言:javascript
复制
public actionSome()
{ $dataProvider = new ActiveDataProvider();
            $dataProvider->query = Orders::find()->all();
return $this->render('some',['dataProvider'=>$dataProvider]);
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-06-20 17:06:05

不要使用Html::a(),而是使用Html::button()where按钮id = some_item_id,然后编写以下JS代码

代码语言:javascript
复制
 $('.buttons_class').click(function(){
            var selection;
            do{
                selection = parseInt(window.prompt("Please enter a number from 1 to 100", ""), 10);
            }
            while(isNaN(selection));
            if(!isNaN(selection))
            {
                $.post("some",{id:45,prompt_value:selection}, function(response)
                {
                    console.log(response);
                    $.pjax.reload({container:'#pjax-orders_table'});
                });
            }
            })
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30955448

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档