-
-
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
Popover's content function is executed twice #12563
Comments
This is intentional, AFAICT. |
Yes, it checks for emptyness, I don't see any point of this issue. |
Possibly we could rework things so that the function is only called once. (It might be an expensive function.) |
Yes. 2014-02-11 7:50 GMT+01:00 Chris Rebert notifications@github.com:
Zlatan Vasović - ZDroid |
Hi, If I understand correctly, this will be addressed in Bootstrap v.3.2.0. In the meantime, is there a turnaround? I am running an AJAX call on content: function() and I'd like to have it run only once... Of course, I can go via the "show.bs.popover" event, but is there an easier / cleaner way? (excuse my english, it is a foreign language to me) |
Yep, the popover function isn't cached. If you want cacheing, you should just do it yourself locally :) $('[data-toggle="tooltip"]').tooltip({
title: function () {
if (this.cache) return this.cache
// otherwise do a bunch of crazy string
// manipulation and whatever else
return this.cache = 'hello'
}.bind({})
}) |
I still think that calling the content function twice violates the Principle of Least Surprise. |
Yeah - I agree. Why was this closed? Why can't the "check for emptyness" store the content in a variable and reuse it? |
Could this behavior at least be documented in the main instructions. Its fairly bamboozling behavior if its not expected. I'm not sure this really should be a closed issue until its either corrected or documented! |
Reopening since we ought to document this. |
A quickfix could be to ensure you have a title in the popover, then this won't happen. Not a beauty, but instead of changing the source..... |
Fix #12563: Elaborate that popover('show') checks title/content
When title or content is empty, the function in content is executed twice. This is VERY surprising. I'm lucky that my friend spotted it, I haven't even noticed it. My use case was that after the click I was replacing the content. So, the only way to get rid of duplicated, costly AJAX request (which was in the content function) was to set the title and that was my workaround. But, I don't want the title, it looked better without. It's only poor workaround. It shouldn't work like this that in order to NOT have double request (which is a "feature" that nobody wants) I have to set... a title. It's totally not connected logically, it's bug from my perspective and should be fixed. That callback, no matter what, should be executed only once, like other 99,9%, normal callbacks out there. |
+1 |
Locking since this is already on our list for reconsideration in Bootstrap v4. |
When using the content function for a popover, it seems to be executed twice when the trigger occurs.
The text was updated successfully, but these errors were encountered: