Yii2 Modal Dialog on Gridview view and update button shows same content for both buttons

前端 未结 1 1487
庸人自扰
庸人自扰 2020-12-18 11:20

With reference to How to implement Yii2 Modal Dialog on Gridview view and update button?, the problem is currently solved on enabling Yii2 gridview view button with modal di

相关标签:
1条回答
  • 2020-12-18 11:49

    This happens because of this line:

    $('.modal-body').html(data);
    

    That means the html will be inserted into each modal body.

    In case of multiple modals in one page you should specify exact modal which you want to change.

    Change this line to:

    $('#activity-modal').find('.modal-body').html(data);
    

    Additionally you can clear modal's content using events:

    $('#activity-modal').on('hidden.bs.modal', function (e) {
        $(this).find('.modal-body').html('');
    })
    

    Check the events section in official Boostrap 3 documentation to modals.

    0 讨论(0)
提交回复
热议问题