You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Popover's content function is executed twice #12563
This is intentional, AFAICT. Popover.prototype.hasContent checks if the tooltip/popover is empty and based thereon decides if it should be shown in the first place.
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)returnthis.cache// otherwise do a bunch of crazy string// manipulation and whatever elsereturnthis.cache='hello'}.bind({})})
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!
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.....
When I trigger my popover to load $getJSON I immediatly efter returns a string "loading.....", I would actually have expected this string to show up and fix the issue until the request returned and I could replace the content.....but it don't?
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.
Activity
hnrch02 commentedon Feb 3, 2014
This is intentional, AFAICT.
Popover.prototype.hasContentchecks if the tooltip/popover is empty and based thereon decides if it should be shown in the first place.zlatanvasovic commentedon Feb 11, 2014
Yes, it checks for emptyness, I don't see any point of this issue.
cvrebert commentedon Feb 11, 2014
Possibly we could rework things so that the function is only called once. (It might be an expensive function.)
zlatanvasovic commentedon Feb 11, 2014
Yes.
2014-02-11 7:50 GMT+01:00 Chris Rebert notifications@github.com:
Zlatan Vasović - ZDroid
apaulo commentedon Apr 30, 2014
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)
fat commentedon Jun 10, 2014
Yep, the popover function isn't cached. If you want cacheing, you should just do it yourself locally :)
cvrebert commentedon Jun 10, 2014
I still think that calling the content function twice violates the Principle of Least Surprise.
danieldean44 commentedon Jun 10, 2014
Yeah - I agree. Why was this closed? Why can't the "check for emptyness" store the content in a variable and reuse it?
shayneoneill commentedon Sep 23, 2014
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!
2 remaining items
hnrch02 commentedon Sep 23, 2014
Reopening since we ought to document this.
rasmuschristensen commentedon Sep 25, 2014
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.....
When I trigger my popover to load $getJSON I immediatly efter returns a string "loading.....", I would actually have expected this string to show up and fix the issue until the request returned and I could replace the content.....but it don't?
Merge pull request #14716 from blankmaker/docs/fix-12563
Fix twbs#12563: Reiterate that empty tooltips+popovers do not get dis…
Poprawka #3 Zdublowane żądanie AJAX po kliknięciu na nazwisko
AdamStelmaszczyk commentedon Dec 5, 2014
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.
rubystar commentedon Mar 12, 2015
+1
cvrebert commentedon Mar 12, 2015
Locking since this is already on our list for reconsideration in Bootstrap v4.