Closed (fixed)
Project:
Bootstrap
Version:
7.x-3.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Reporter:
Created:
17 Oct 2013 at 21:37 UTC
Updated:
27 Nov 2013 at 05:37 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
markhalliwellFrom http://getbootstrap.com/2.3.2/javascript.html#tooltips
The equivalent for BS3: http://getbootstrap.com/javascript/#popovers-usage under the "Markup" section:
Tabs are activated automatically via the "data-api":
https://github.com/twbs/bootstrap/blob/master/js/tab.js#L127-L133
And you can see that popovers and tooltips are not:
https://github.com/twbs/bootstrap/blob/master/js/popover.js#L116
https://github.com/twbs/bootstrap/blob/master/js/tooltip.js#L385
I agree this is rather confusing. Perhaps we should throw a theme setting in, enabled by default, to auto load these plugins:
http://drupalcode.org/project/bootstrap.git/blob/refs/heads/7.x-3.x:/js/...
Comment #2
markhalliwellComment #3
valkum commentedWill look tomorrow afternoon into it (GMT+2). If anyone got time before, np.
Comment #4
valkum commentedWhat about this?
When you add elements using data-toggle via ajax you have to call .popover or .tooltip again.
Maybe we can came up with an .on() solution? Or is there no need to handle this in this base theme? Mark?
Comment #5
markhalliwellI'd follow the tab data-api solution: https://github.com/twbs/bootstrap/blob/master/js/tab.js#L127-L133
Comment #6
valkum commentedThe problem with this is,
with popover('show') the popover doesn't close, it opens on every click.
with popover() the first click doesn't open the popover.
We could use one() instead of on(), But i'm not sure if this applies to new element as well.
Here is a patch with one()
Comment #7
markhalliwellNot exactly like tabs, popovers have their own methods and events: http://getbootstrap.com/javascript/#popovers, specifically
$('#element').popover('toggle')"JavaScript"
bootstrap_popoverandbootstrap_tooltipis fine.Also, perhaps we should give the users which "event" they would like this triggered on (ie: click, mouseup, mousemove, etc).
Comment #8
valkum commentedI think, in base theme, we should stick with the default events that are bound to the element on .popover() .tooltip()
I think we should stay with .one on tooltip.
I'm not sure if there is need to use on with toggle on popovers.
The only thing we need to do is init. the popover for this element and show it.
Comment #9
valkum commentedHere is a patch with fixed #7.1 and #7.2
I'd like to stick with default events and not to bind 2 event listener to the same element.
Data-api tabs are different, as there is no listener defined in the plugin itself.
popover and tooltip bind event listeners on first call of .popover() or .popover(option) / .tooltip() or tooltip(option)
I think the $.one() solution is the best way.
Comment #10
markhalliwellOne isn't the best way, it will only fire once (per click or hover) instead of continuously. It should be using
.on.Comment #11
valkum commentedi came up with this solution. I'm not sure if there is a better way.
This way the .popover(option) function is only called once on the specific element ([data-toggle="popover"])
and the clicks after this initial click are handled by popovers own event listener.
The same for tooltips.
Comment #12
valkum commentedComment #13
markhalliwellThe patch in #12 looks to contain several other patches, please reroll with just the changes for this issue (FWIW, I typically create separate branches from 7.x-3.x per issue so I don't x-patch issues).
Comment #14
valkum commentedsry, don't know from where this came. I have an branch per issue. Think messed somethin up with unstashed/uncommited changes.
here is the rerolled patch
Comment #15
valkum commentedComment #16
markhalliwellSorry @valkum, the more I thought about this, this is more of what I had in mind:
Committed a5223b6 to 7.x-3.x: