Backbone.js 在主干木偶布局上设置工具提示

Backbone.js 在主干木偶布局上设置工具提示,backbone.js,marionette,Backbone.js,Marionette,如何在所有区域和视图上添加工具提示 这是我的layout.js: return Backbone.Marionette.Layout.extend({ template: bearBoxLayoutTemplate, regions: { header: ".header", sidebar: ".sidebar", workspace: ".workspace" }, // onShow also

如何在所有区域和视图上添加工具提示

这是我的layout.js:

  return Backbone.Marionette.Layout.extend({
     template: bearBoxLayoutTemplate,

     regions: {
        header: ".header",
        sidebar: ".sidebar",
        workspace: ".workspace"
     },

     // onShow also didn't work
     onRender: function()
     {
        // tool tips
        $('.tooltips').tooltip();  
     }
  });
下面的代码不起作用,但是如果我添加

  $('.tooltips').tooltip(); 
在每个视图上,它都有效。除了在每个视图上都添加代码,还有其他方法吗


谢谢

通过在布局的initialize函数上侦听区域的show事件来实现这一点

代码如下:

        // listen to the region on show event
        this.sidebar.on("show", function(view){
          // manipulate the `view` or do something extra
          // with the region via `this`
          this.$el.find('.tooltips').tooltip();  
        });

        // listen to the region on show event
        this.workspace.on("show", function(view){
          // manipulate the `view` or do something extra
          // with the region via `this`
          this.$el.find('.tooltips').tooltip();  
        });