-
-
Notifications
You must be signed in to change notification settings - Fork 79k
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
closed.bs.alert fires before remove() #12379
Comments
@fat What do you think? |
FYI I've been using a modified .min.js on something live for a while with the above change. Have not seen any undesired effects. |
@EnsignR I think a pull request implementing this change would be welcome. |
I did fork and edit, but I couldn't figure out how to create a pull req. for just that one change (rather than include some I also made to dropdown.js as well). :\ |
first reaction is, using detach doesn't clean up the memory… and jquery keeps all the data, etc around on that object, so it's not quite ideal |
that said, i could see wanting to wait for the element to be removed first |
we could do jQuery.cleanData($parent.detach().trigger('closed.bs.alert')) even though cleanData is undocumented… and could change/disappear… |
.empty() calls jQuery.cleanData.and is documented.
|
actually we can just do empty isn't quite right because it wont call cleanData on the parent i dont think |
Added call to remove() after event fires to clean up data as per discussion at twbs#12379
fires closed.bs.alert *after* DOM detach() as per #12379
fixed |
Commenting because this fix ended up breaking the ability for a parent view to listen to the alert object. The core of the problem I think is the "fires after element is removed from DOM" directive; which conflicts with the desire to listen for the event in the same manner that one can listen to tooltips, modals, etc, where the owner of the eventHandler is not the Bootstrap object in question. If the answer is just "works as designed, work around that problem", that is fine, but I wanted to check if there might be a solution first. I made an example is with Backbone/Marionette, but could be anything where the alert is a child of a view listening for the bootstrap events. |
As mentioned in #10199 the event closed.bs.alert fires before elements are removed from the DOM.
I have made a jsfiddle to illustrate this here http://jsfiddle.net/ensignr/NFrFc/
I believe the problem lies in Alert.removeElement() in /js/alert.js:45
Here remove() is called after the trigger() in the chain.
The following change, where I detach() first, seem to fix things.
I managed to quickly patch the 3.0.3 minified version bootrap.min.js which seems to work. You can see it here http://jsfiddle.net/ensignr/6VjPP/ (for as long as I keep the modified code hosted)
I've tried both the patched and non patched jsfiddles (as well as the project that lead me to discover this) in both Chrome 32.0.1700.76 and IE11 on Win7.
[Apols if I've missed/messed up the markup or something else, but I've had to join all the things to submit this bug report. It's been quite an effort :) ]
The text was updated successfully, but these errors were encountered: