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/tooltip selector option needs documentation #4215

Closed
jakepetroules opened this Issue Jul 29, 2012 · 11 comments

Comments

Projects
None yet
@jakepetroules

jakepetroules commented Jul 29, 2012

The documentation for the selector option for popovers and tooltips currently states "if a selector is provided, tooltip objects will be delegated to the specified targets". This description is not very helpful and appears to confuse a good number of people, including myself until I figured out what it actually does (also see #2091).

Explanation: 'selector' is used internally in conjunction with jQuery.on in order to allow markup dynamically inserted in the DOM, to trigger tooltips and popovers. I've created an interactive jsFiddle illustrating its usage: http://jsfiddle.net/KPeKS/4/

tl;dr: selector = jQuery.on support

I therefore propose that the documentation be improved, making note that 'selector' makes the plugins use jQuery.on and a short explanation of what that does, for those who may not be familiar with the function, along with the following sample code:

$('body').tooltip({
    selector: '[rel="tooltip"]'
});

$('body').popover({
    selector: '[rel="popover"]'
});

I'll leave exactly how it might be worded to @mdo / @fat.

@badlydrawnrob

This comment has been minimized.

Show comment
Hide comment
@badlydrawnrob

badlydrawnrob Aug 26, 2012

I had some trouble with this too, thanks!

badlydrawnrob commented Aug 26, 2012

I had some trouble with this too, thanks!

@gustavohenke

This comment has been minimized.

Show comment
Hide comment
@gustavohenke

gustavohenke Sep 1, 2012

I agree on this, it's confusing.

gustavohenke commented Sep 1, 2012

I agree on this, it's confusing.

@danielristic

This comment has been minimized.

Show comment
Hide comment
@danielristic

danielristic Oct 4, 2012

Got confused by the documentation as well. Thought data-selector was a way to point to another element in the page so its contents are displayed inside the popover, instead of the data-content attribute contents.

danielristic commented Oct 4, 2012

Got confused by the documentation as well. Thought data-selector was a way to point to another element in the page so its contents are displayed inside the popover, instead of the data-content attribute contents.

@dbwinger

This comment has been minimized.

Show comment
Hide comment
@dbwinger

dbwinger Nov 1, 2012

Thanks for the explanation @jakepetroules !

dbwinger commented Nov 1, 2012

Thanks for the explanation @jakepetroules !

@mdo

This comment has been minimized.

Show comment
Hide comment
@mdo

mdo Dec 2, 2012

Member

Please submit a pull request with the suggested edits and we can ge them in there. Until then, closing out. Thanks!

Member

mdo commented Dec 2, 2012

Please submit a pull request with the suggested edits and we can ge them in there. Until then, closing out. Thanks!

@mdo mdo closed this Dec 2, 2012

@pykler

This comment has been minimized.

Show comment
Hide comment
@pykler

pykler Feb 26, 2013

Same issue here using 2.3.0 ... bootstrap is ignoring the data-trigger (atleast) when using the selector as mentioned in this bug report.

pykler commented Feb 26, 2013

Same issue here using 2.3.0 ... bootstrap is ignoring the data-trigger (atleast) when using the selector as mentioned in this bug report.

@leadVisionary

This comment has been minimized.

Show comment
Hide comment
@leadVisionary

leadVisionary Mar 7, 2013

Pull request on the docs meaning forking the javascript.html file and editing? Doing that. Is that really the preferred way? Seems like each section should live in a mustache/other template and the whole docs should be dynamically assembled.

leadVisionary commented Mar 7, 2013

Pull request on the docs meaning forking the javascript.html file and editing? Doing that. Is that really the preferred way? Seems like each section should live in a mustache/other template and the whole docs should be dynamically assembled.

@danishsatkut

This comment has been minimized.

Show comment
Hide comment
@danishsatkut

danishsatkut Jun 4, 2013

@jakepetroules Thanks for clearing it up.

danishsatkut commented Jun 4, 2013

@jakepetroules Thanks for clearing it up.

@lhealey77

This comment has been minimized.

Show comment
Hide comment
@lhealey77

lhealey77 Mar 17, 2014

Read somewhere that jquery now suggests attaching ".on" to the document. (instead of the body as in this thread)

So you might try...
$(document).popover({selector:'.popover-source-dynamic[data-trigger="hover"]', trigger:'hover'});

It seems to work for me. (although admittedly didn't spend a lot of time on this)

lhealey77 commented Mar 17, 2014

Read somewhere that jquery now suggests attaching ".on" to the document. (instead of the body as in this thread)

So you might try...
$(document).popover({selector:'.popover-source-dynamic[data-trigger="hover"]', trigger:'hover'});

It seems to work for me. (although admittedly didn't spend a lot of time on this)

@jgauffin

This comment has been minimized.

Show comment
Hide comment
@jgauffin

jgauffin May 22, 2014

the documentation is still cryptic for tooltips

jgauffin commented May 22, 2014

the documentation is still cryptic for tooltips

@cipster

This comment has been minimized.

Show comment
Hide comment
@cipster

cipster Nov 22, 2014

Thank you. It really helped me out

cipster commented Nov 22, 2014

Thank you. It really helped me out

@twbs twbs locked and limited conversation to collaborators Jan 4, 2015

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.