Kirill Salykin
Kirill Salykin

Reputation: 711

didInsertElement event and unless block

I'm trying this:

didInsertElement: function(){
    this.$('[data-hover="dropdown"]').dropdownHover();
  },

And i have anchor with data-hover="dropdown" in {{unless}} block.

But the anchor isnt in DOM at didInsertElement.

Is there any other event for this?

Upvotes: 0

Views: 110

Answers (1)

Mike Grassotti
Mike Grassotti

Reputation: 19050

There are a few ways to approach this. One possibility is to add an observer that watches for changes to the same property as the unless block. When the observer triggers it would add the dropdownHover() code to the afterRender queue.

Far simpler is to make the anchor tag a custom view and customize it's didInsertElement hook. Something like:

App.DropDownLink = Ember.View.extend({
  tagName: 'a'
  didInsertElement: function(){
    this.$('[data-hover="dropdown"]').dropdownHover();
  }
})

Upvotes: 1

Related Questions