带有backbone.marionette和twitter bootstrap的模态工具提示

时间:2013-04-26 09:40:35

标签: backbone.js twitter-bootstrap tooltip modal-dialog marionette

我在backbone.marionette应用程序中有一个按钮,它打开一个模态,我想在这个模态中有工具提示。

在模态区域中显示模态的视图:

class MyApp.Views.UserInfos extends Backbone.Marionette.ItemView

    template: 'backbone/templates/user_infos'

    events:
        'click button': 'send_invitation'

    send_invitation: () ->
        invitation = new MyApp.Models.Invitation({username: @model.get('name')})
        modal_view = new MyApp.Views.InvitationSettings({model: invitation})
        App.modal.show(modal_view)
        $("#modal").modal('show')

我想要工具提示的模态视图:

class MyApp.Views.InvitationSettings extends Backbone.Marionette.ItemView

    template: 'backbone/templates/invitation_settings'

    onShow: () ->
        $(".icon-question-sign").tooltip()

我在显示区域时初始化工具提示,但它不起作用。更糟糕的是,当我悬停工具提示可能是模态窗口关闭的区域时,背景不会消失。

1 个答案:

答案 0 :(得分:0)

您应该使用onRender回调。

这是一个小提琴: http://jsfiddle.net/puleos/gag5a/

var ToolView = Backbone.Marionette.ItemView.extend({
    template:"#tool-template",
    tagName: "span",
    onRender: function() {
        this.$el.find('a').tooltip();
    }
});