4

I have the following code:

 [   'format' => 'raw',
            'contentOptions'=>['style'=>'width: 5px;'],
            'value' => function($model) {
                if($model->id == Yii::$app->user->identity->id) {
                    return  Html::a('<i class="glyphicon glyphicon-share-alt"></i>',[''],['id'=> 'replay-to-'. $model->ID_KOMENTAR ]).' '. 
                            Html::a('<i class="glyphicon glyphicon-pencil"></i>', ['update', 'id' => $model->id]).' '.
                            Html::a('<i class="glyphicon glyphicon-trash"></i>', ['delete', 'id' => $model->id], ['data' => ['confirm' => 'Do you really want to delete this element?','method' => 'post']]);
                }
                return Html::a('<i class="glyphicon glyphicon-share-alt"></i>',['feedback', 'id' => $model->id],['id'=> 'replay-to-'. $model->ID_KOMENTAR ]);
            },
        ],

I would like the replay button to avoid the href which makes my page redirect to another page because I want to click and put jquery there.

I tried with this :

Html::a('<i class="glyphicon glyphicon-share-alt"></i>',[''],['id'=> 'replay-to-'. $model->ID_KOMENTAR ])

but it still redirects to another page.

4

2 回答 2

3

要将href值设置为#

Html::a('<i class="glyphicon glyphicon-share-alt"></i>', '#', ['id'=> 'replay-to-' . $model->ID_KOMENTAR]);

HTML 输出将是:

<a id="replay-to-1" href="#"><i class="glyphicon glyphicon-share-alt"></i></a>

要完全删除href属性使用null(它是第二个参数的默认值):

Html::a('<i class="glyphicon glyphicon-share-alt"></i>', null, ['id'=> 'replay-to-' . $model->ID_KOMENTAR]);

HTML 输出将是:

<a id="replay-to-1"><i class="glyphicon glyphicon-share-alt"></i></a>
于 2015-09-03T03:33:03.070 回答
1

尝试这个

Html::a('<i class="glyphicon glyphicon-share-alt"></i>', false, ['id'=> 'replay-to-'. $model->ID_KOMENTAR ]);

于 2015-09-03T04:16:46.013 回答