Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dispose doesnt work properly #140

Open
Gawrion opened this issue Jul 7, 2021 · 1 comment
Open

dispose doesnt work properly #140

Gawrion opened this issue Jul 7, 2021 · 1 comment

Comments

@Gawrion
Copy link

Gawrion commented Jul 7, 2021

Hi Mistic!

jQuery 3.6.0, Bootstrap 4.3.1, popper 1.14.7 Bootstrap Confirmation 4.2.1

After using dispose method on created instance its not possible to initialize new instance of confirmation. Example of bug:

<link rel="stylesheet" href="\css\bootstrap.css">
<script src="/js/jquery.js"></script>
<script src="/js/popper.js"></script>
<script src="/js/bootstrap.js"></script>
<script src="/js/bootstrap-confirmation.js"></script>

<button class="btn btn-default btn-sm btn-success " data-toggle="confirmation" id="btn-1">BTN1</button><br>
<button class="btn btn-default btn-sm btn-success " data-toggle="confirmation" id="btn-2">BTN2</button><br>
<button class="btn btn-default btn-sm btn-success " data-toggle="confirmation" id="btn-3">BTN3</button><br>

<script>
    confirmation();

    function confirmation() {
        let confirmOptions1 = {
            rootSelector: '[data-toggle=confirmation]',
            title: 'OPCJA 1',
        }
        let confirmOptions2 = {
            rootSelector: '[data-toggle=confirmation]',
            title: 'OPCJA 2',
        }
        // using popover works fine; using confirmation extension not working
        let confirmationInstance = $('[data-toggle=confirmation]').confirmation(confirmOptions1);

        $('#btn-1').confirmation('dispose');

        // new instance on #btn-1 after dispose works only with popover
        $('#btn-1').confirmation(confirmOptions2);
    }
</script>
@Gawrion
Copy link
Author

Gawrion commented Jul 7, 2021

Quick (but i don't know if not also buggy) workaround is to .removeData and remove event handler (.off) from element before settin new instance:

            $('#smietnik-btn-1').removeData();
            $('#smietnik-btn-1').off();
            $('#smietnik-btn-1').confirmation(confirmOptions2);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant