-
-
Notifications
You must be signed in to change notification settings - Fork 78.9k
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
Remove popover content with .children().detach() instead of .empty() #14244
Conversation
…so it can be reused
@@ -46,7 +46,8 @@ | |||
var content = this.getContent() | |||
|
|||
$tip.find('.popover-title')[this.options.html ? 'html' : 'text'](title) | |||
$tip.find('.popover-content').empty()[ // we use append for html objects to maintain js events | |||
$tip.find('.popover-content').children().detach() | |||
$tip.find('.popover-content')[ // we use append for html objects to maintain js events |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to split this up into separate lines, you can use .end()
after the .detach()
and get the original set back.
Good point. Updated accordingly. |
/cc @fat |
Remove popover content with .children().detach() instead of .empty()
cool thanks! |
@programcsharp Do you have an example of something that broke with the |
I believe this was an issue of reuse of the same content in a popover over Empty destroys jQuery elements in such a way that they can't properly be @programcsharp https://github.com/programcsharp Do you have an example of — |
The specific scenario was a popover using the body container layout, If you can't get a repro, let me know and I'll hunt up an example.
|
@programcsharp Yeah, I grok what the issue is, and tried to write a testcase, but was unable to make the test fail after reverting your fix... 😕 |
Here you are: http://jsfiddle.net/1frd7kgu/ Click the "repro .empty() issue" button once. Popover comes up, button inside works. Close popover. Click button again. Button inside doesn't work now, or ever again. |
@programcsharp Thanks a million! |
Special thanks to @programcsharp [skip validator]
Special thanks to @programcsharp [skip validator]
Add regression test for #14244.
Using .empty() is bad because it blows up the content. If you're planning on using it later or swapping it around, you can't. jQuery won't let you reattach the content or rewire events to it. Instead, do .children().detach().
This is a refinement of the fix in #13165.