How to add a tooltip on all regions and views?

Here is my 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();  
     }
  });

The code below doesn't work, but if I add the

  $('.tooltips').tooltip(); 

on every view, it works. Is there any other way instead of putting the code on every view?

Thanks!

有帮助吗?

解决方案

Got this to work by listening to the show event of the regions on the initialize function of the layout

Here's the code:

        // 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();  
        });
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top