dagda1
dagda1

Reputation: 28810

Firing custom events from ember.js backbone style

I have an infinite scroller that adds new elements to a page as the user scrolls. I would like to have multiple subscribers be able to bind to an event that I fire every time the new elements are added.

Is it possible for me to raise a custom event like I can in Backbone?

For example in backbone I can create an evented model like this:

this.vent = _.extend({}, Backbone.Events);

I can then bind events like this:

this.vent.bind('my:custom:event', this.handler);

And I can then fire them like this:

this.trigger('my:custom:event', args);

Can I use Ember.evented like this or is there a better way?

Upvotes: 5

Views: 2846

Answers (1)

mspisars
mspisars

Reputation: 854

If you would like Ember.js to recognize the events, you can add those events to your App definition. Check out this Understanding Ember.js article, right below the list of "included" events.

Upvotes: 2

Related Questions