yii2 PJAX How to show modal after doing pjax reload?

1.2k views Asked by At

i have code like this :

        $('.btnRemove').on('click', function(){ 

            var id = $(this).attr('id');
            $.ajax({
                    type     :'POST',
                    dataType : 'json',
                    data : ({delid : id}),
                    url  : 'deletecurrentstore',
                    success  : function(response) {
                        $('#row'+id).remove();
                        $.pjax.reload({container: '#gridremainstore'});

                        $('#myModal').on('hidden.bs.modal', function (e) {
                            $('#myModal').modal('show');
                        })
                }
            })
        })

how to show the modal again after page reload? is it possible? i want to show it because i have 2 gridview called current store and all store, they are separated by tab but in same modal, so two gridview in one modal. in all store i show all list store and in current store i show the choosen store. in current store i have a remove button to remove the choosen store, the problem is when i click remove in current store, in the all store not direct update. I try to use pjax reload but with it reload entire full page and close the modal. so how pjax reload still work but show the modal? so after reload page, automatic show the modal. i am using this code and not work. thanks for care and understanding.

1

There are 1 answers

0
Chinmay Waghmare On

Try:

$(document).on('pjax:success', function(event, data, status, xhr, options) {
      $('#myModal').modal('show');
});