Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HusseinMorsy/6c61dad6c3c3c6815860fca91411cd89 to your computer and use it in GitHub Desktop.
Save HusseinMorsy/6c61dad6c3c3c6815860fca91411cd89 to your computer and use it in GitHub Desktop.
Actions Part 1
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Weekend',
actions: {
save() {
const person = {
firstName: this.get('firstName'),
lastName: this.get('lastName'),
};
this.set('saved', person);
this.transitionToRoute('show');
},
cancel() {
this.set('firstName', '');
this.set('lastName', '');
}
}
});
import Ember from 'ember';
import config from './config/environment';
const Router = Ember.Router.extend({
location: 'none'
});
Router.map(function() {
this.route('show');
});
export default Router;
<h1>Welcome to {{appName}}</h1>
<button {{action "cancel"}}>Cancel</button>
<form {{action "save" on="submit"}}>
<p>first name{{input value=firstName}}</p>
<p>last name{{input value=LastName}}</p>
<button type="submit">Save</button>
</form>
<p>saved: {{saved.firstName}} {{saved.lastName}}</p>
{
"version": "0.8.1",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "2.5.1",
"ember-data": "2.5.2",
"ember-template-compiler": "2.5.1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment