Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firing custom events from ember.js backbone style

Tags:

ember.js

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?

like image 293
dagda1 Avatar asked Nov 03 '22 21:11

dagda1


1 Answers

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.

like image 55
mspisars Avatar answered Jan 04 '23 15:01

mspisars