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

.on('hidden') event called only once #202

Closed
david-nguyen opened this issue Jan 7, 2014 · 10 comments
Closed

.on('hidden') event called only once #202

david-nguyen opened this issue Jan 7, 2014 · 10 comments

Comments

@david-nguyen
Copy link

For some reason the original modal event hidden is only called once when the modal is closed. Can be reproduced on the demo page by entering this into console and opening the first modal repeatedly.

$('#responsive').on('hidden', function (e) {console.log('close')});
@fultke01
Copy link

Same with show, show.bs.modal, shown, and shown.bs.modal. This is referring to Bootstrap 3 for clarity.

@david-nguyen
Copy link
Author

I've found the culprit on line 84 of bootstrap-modal:

if (!this.isShown || e.isDefaultPrevented()) return (this.isShown = false);

should be:

if (!this.isShown || e.isDefaultPrevented()) return (this.isShown = true);

@jschr
Copy link
Owner

jschr commented Jan 15, 2014

See my comment here: #199 (comment)

@jschr
Copy link
Owner

jschr commented Feb 5, 2014

0236f06 should fix this. Please update to the latest version and let me know.

Thanks

@david-nguyen
Copy link
Author

I've tried the update but it still doesn't work in my use case:

  • hide.bs.modal: intercept the event and check if form change has occured, showing an alert (return true or false)
on('hide.bs.modal', function (e) {
    if( ! confirm(cancelEditMsg))
        return false;
    else
        return true;
});

Unable to close or call modal('hide'). I'll see if I can set up a fiddle, but the work around allowed me to do what I needed.

@alissonbarison
Copy link

I'm using version:
v2.2.5

when I write:

i = 1;
$ ('#modalBootstrap'). on ('hide.bs.modal', function () {
    console.log (i);
    i ++;
});

whenever I close the modal the var i should increase and console show the value of i, but this only happens the first time I close the modal.
what may be missing in my code?

@jschr
Copy link
Owner

jschr commented Nov 24, 2014

This seems to be a dup of #228. A workaround is provided in that issue

@alissonbarison
Copy link

how to solve

@jschr
Copy link
Owner

jschr commented Nov 24, 2014

$modal.on('show', function () { ... }
$modal.on('shown', function () { ... }
$modal.on('hide', function () { ... }
$modal.on('hidden', function () { ... }

@jschr
Copy link
Owner

jschr commented Nov 24, 2014

Closing as dup

@jschr jschr closed this as completed Nov 24, 2014
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

4 participants