I asked Terry to answer a little further and thought that I came up with a simple general solution to this problem.
I created a bootstrap-popover component, for example:
App.BootstrapPopoverComponent = Ember.Component.extend({ tagName: 'div', //whatever default you want... div is default anyway here classNames: '', //whatever default you want placement: 'bottom', //whatever default you want didInsertElement: function () { var component = this, contents = this.$('.popoverJs'); component.$().popover({ animation: false, placement: component.get('placement'), html: true, content: contents }).on('show.bs.popover', function () { contents.removeClass('hide'); }); }, willDestroyElement: function () { this.$().popover('destroy'); } });
Here is the appropriate template:
<script type="text/x-handlebars" id="components/bootstrap-popover"> {{title}} <div class="popoverJs hide"> {{yield}} </div> </script>
Note the use of the Hide class to hide the original content initially. This class is simply "display: none". Without this, everything will not work the way you hope.
Once you do this, you can do something like this when you want a popover:
{{#bootstrap-popover title="My Fancy Popover" tagName="button"}} <ul> <li>my</li> <li>awesome</li> <li>popover</li> <li>contents</li> <li>example</li> </ul> {{/bootstrap-popover}}
The content should be anything, anything — any arbitrary HTML, component rendering or partial, etc. Naturally, you can specify other tag names, class names, title, placement, etc., as you see fit.
I hope this solution helps.
eeggers
source share