Skip to content

Instantly share code, notes, and snippets.

@mamut
Created July 29, 2015 21:00
Show Gist options
  • Save mamut/e4501d749c978b0658a6 to your computer and use it in GitHub Desktop.
Save mamut/e4501d749c978b0658a6 to your computer and use it in GitHub Desktop.
sending-multiple-actions
import Ember from 'ember';
export default Ember.Component.extend({
actions: {
submit() {
this.sendAction('submit', {
name: this.get('name'),
bio: this.get('bio')
});
},
cancel() {
this.sendAction('cancel');
}
}
});
import Ember from 'ember';
export default Ember.Controller.extend({
actions: {
createUser(user) {
alert(`Created user ${user.name} with bio ${user.bio}.`);
},
cancelUserCreation() {
alert("Canceled user creation.");
}
}
});
<form {{action "submit" on="submit"}}>
<p>
<label>Name {{input type="text" value=name}}</label>
</p>
<p>
<label>Bio {{textarea value=bio}}</label>
</p>
<button {{action "cancel"}}>Cancel</button>
<input type="submit">
</form>
{{user-form submit="createUser" cancel="cancelUserCreation"}}
{
"version": "0.4.0",
"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.5/ember.js",
"ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/1.13.5/ember-data.js"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment