Yii Framework Forum: call Modal from Action Column Hyperlink - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

call Modal from Action Column Hyperlink How to get a Modal from an normal Hyperlink in Action Column Rate Topic: -----

#1 User is offline   s.oli 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 13
  • Joined: 15-November 15

Posted 08 February 2018 - 12:05 PM

I search for a solution for clicking on a link in an ActionColumn - Action to open a Modal.

thats not working

return Html::a('<span class="glyphicon glyphicon-earphone"></span>',
             Url::toRoute(['controlloer/createlink','id' => '1']), 
             [ 'id' => 'modalCall',
             ]);
 



For buttons there is a good Dokumentation for handling it.

My Solution helps maybe other, or better solution will come up:


View.php
return Html::a('<span class="glyphicon glyphicon-earphone"></span>',
           "javascript:void(0)", 
           [
               'id' => 'myModal',
               'value'=>Url::toRoute(['call/createlink','id' => '1'])// modalCall
           ]);
 
<?php
    Modal::begin([
        'header' => '<h4></h4>',
        'id' => 'modal',
        'size' => 'modal-lg',
    ]);
    echo "<div id='modalContent'>Modal</div>";
    Modal::end();
    ?>


main.js

 
$(function(){
    $('#myModal').click(function(){
        $('#modal').modal('show')
            .find('#modalContent')
            .load($(this).attr('value'))
    });
});


controller.php
public function actionCreatelink($id)
    {
        $model = new Call();
        $model->cid = $id;
       
        if ($model->load(Yii::$app->request->post()) && $model->save()) {
            return $this->redirect(Yii::$app->request->referrer);
        } else {
            return $this->renderAjax('create', [
                'model' => $model,
            ]);
        }
    }

2

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users