wryrych
wryrych

Reputation: 1765

how to initialize plugin when an app is ready?

I'm trying to configure iScroll plugin. According to documentation it should load when DOM is ready. I tried with didInsertElement on a view but it didn't work as expected.

Unfortunately, I can't access any Ember views inside app ready hook - it returns no elements: foo = $('.ember-view').length === 0 // true

When I init the plugin manually, it works.

So, how can I init additional plugins that need DOM elements rendered with handlebars?

Upvotes: 0

Views: 433

Answers (1)

eduard
eduard

Reputation: 1495

The general idea is to do this in the didInsertElement. Say you have a jQuery plugin that needs to be run when things are in the DOM:

didInsertElement: function() {
   $("#selector").plugin();
}

This should solve your problem. Obviously, the plugin JavaScript has to be already loaded here. You should do that in the conventional way.

Upvotes: 1

Related Questions