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
Simplify the customization of popover #19415
Comments
I'm not sure what you're suggesting. Perhaps you could post a JSFiddle/JSBin of this in action? |
I second this. Take a look at the myriad answers to this question on stack overflow to get a sense for how often it comes up and what kinds of workarounds people are resorting to: http://stackoverflow.com/questions/12170357/dynamically-add-a-class-to-bootstraps-popover-container If I want to style a specific popover, I have several possible approaches:
In the current state of things, I think the best solution is combining the 5th approach with some code that copies something like |
What @fredgate proposes would be a pretty straightforward addition to the For example: Tooltip.prototype.tip = function () { if (!this.$tip) { this.$tip = $(this.options.template) // New className handling if(this.options.className) { this.$tip.addClass(this.options.className); } if (this.$tip.length != 1) { throw new Error(this.type + ' `template` option must consist of exactly 1 top-level element!') } } return this.$tip } Not a huge change but I wonder if the root issue can be solved simply with more visible documentation of the I think any scenario can be covered using Single Use $('#my-popover').popover() .data('bs.popover') .tip() .addClass('my-class-name'); Multiple Matching Selectors $('.my-popovers').popover() .map(function(){ $(this).data('bs.popover') .tip() .addClass('my-class-name') }); |
Was this ever addressed in V4? I've wanted a fix for this too and it seems like it could be done pretty quickly. |
This is a suggestion I have from a long time. I thought it was missing in version 3, and it might be well to allow it in version 4.
When we want to customize the popover (width, content padding...) we actually do not have other choice that to redefine the full template, which is not very readable, maintainable and evolutive.
A better option might be to allow to add a class to the popver, so we could add our custom styles to this class without impacting all the popovers.
Example :
The text was updated successfully, but these errors were encountered: