简体   繁体   中英

Ember.js and Twitter Bootstrap Popover

I'm trying to deploy the popover using ember.js but not sure how to do it.

The contents of the popover must be an element of ember to interact with it.

I've been watching https://github.com/jzajpt/ember-bootstrap but does not include the popover element.

Any ideas? Thanks!

I think, what you try to do will never work, because if your mouse leaves the control, the popover will go away!

App.Popover = Ember.View.extend({
     name: 'myPopover',
     template: Ember.Handlebars.compile('<div class="popover" {{bindAttr name="name"}}><div class="arrow"></div><div class="popover-inner"><h3 class="popover-title">test</h3><div class="popover-content"><p></p></div></div></div>')         
});

App.TextField = Ember.TextField.extend({
    didInsertElement: function() {
        this._super();
        var self = this;                
        Ember.run.schedule('actions', this, function() {
           self.$().popover({
                title: 'title', 
                content: 'content',
                template: $('div[name="myPopover"]')
            });     
        });
    }
});

in the didInsertElement method of your view you can do something like this

didInsertElement: function() {
    var self = this;
    this.$().popover({
        title: self.get('tooltipTitle'), 
        content: self.get('tooltipContent')
    });     
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM