Pregunta

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!

¿Fue útil?

Solución

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();  
        });
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top