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.

EugenSunic
  • 13,162
  • 13
  • 64
  • 86

2 Answers2

3

To set href value to #:

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

The HTML output will be:

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

To completely remove href attribute use null (and it's default value of second paremeter):

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

The HTML output will be:

<a id="replay-to-1"><i class="glyphicon glyphicon-share-alt"></i></a>
arogachev
  • 33,150
  • 7
  • 114
  • 117
1

Try this

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

GAMITG
  • 3,810
  • 7
  • 32
  • 51