Meteor's Iron Router doesn't close modal dialog

◇◆丶佛笑我妖孽 提交于 2019-12-04 07:24:45

There are multiple solutions to this, depending on exactly how you desire the behavior. If you want the modal to hide first, then change the page, you can use a callback on the modal's behavior.

'click #confirm-yes-button': function() {
    Recipes.remove(this._id);
    $('#confirm-modal')
        .on('hidden.bs.modal', function() {
            Router.go('/');
        })
        .modal('hide');
}

As to your question of why the backdrop is visible - its complicated. The backdrop is only hidden once the "hide" animation completes, and changing the page interrupts/stops this behavior.

One of the solution would be to use jQuery methods to remove backdrop once the user has been redirected.

Accounts.onLogin(function(){
    Router.go('/');
    $('.modal-backdrop').remove();
});

However to use this method you need have access to Accounts.login method which can be acquired by adding

gwendall:auth-client-callbacks

package to your meteor project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!