Skip to content

Instantly share code, notes, and snippets.

@jrowlingson
Forked from patrickarlt/application.controller.js
Last active August 28, 2015 18:18
Show Gist options
  • Save jrowlingson/8622e79db2123414a62f to your computer and use it in GitHub Desktop.
Save jrowlingson/8622e79db2123414a62f to your computer and use it in GitHub Desktop.
ember-with-custom-events
import Ember from 'ember';
export default Ember.Controller.extend({
actions: {
doSomethingWithRating: function () {
console.log('action fired from rateitem event with args', arguments);
}
}
});
{{# rate-item action='doSomethingWithRating' }}{{/ rate-item }}
import Ember from 'ember';
export default Ember.Component.extend({
click: function( e ) {
var rating = parseInt( e.target.getAttribute('data-rating') );
this.sendAction( 'action', rating );
}
});
<a data-rating="1">&#9733;</a>
<a data-rating="2">&#9733;</a>
<a data-rating="3">&#9733;</a>
<a data-rating="4">&#9733;</a>
<a data-rating="5">&#9733;</a>
{{ yield }}
{
"version": "0.4.9",
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/1.13.9/ember.js",
"ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/1.13.11/ember-data.js",
"ember-template-compiler": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/1.13.9/ember-template-compiler.js"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment