Navigation Menu

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 alexspeller/6f6d8cb67dc02dafd2d9e9b47314a876 to your computer and use it in GitHub Desktop.
Save alexspeller/6f6d8cb67dc02dafd2d9e9b47314a876 to your computer and use it in GitHub Desktop.
New Twiddle
import Component from '@ember/component';
export default Component.extend({
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
init(){
this._super(...arguments);
this.clickedPeople = [];
},
actions: {
onPersonClick(person){
this.clickedPeople.pushObject(person);
},
onPersonClickWithConfirm(person){
if(confirm("Are you sure?")) {
this.clickedPeople.pushObject(person);
}
}
}
});
import Ember from 'ember';
export default Ember.Route.extend({
model(){
return ['Marie Curie', 'Mae Jemison', 'Albert Hofmann'];
}
});
Without confirm:
{{my-component people=model onPersonClick=(action 'onPersonClick')}}
With confirm:
{{my-component people=model onPersonClick=(action 'onPersonClickWithConfirm')}}
<h1>Cicked people</h1>
<ul>
{{#each clickedPeople as |person|}}
<li>{{person}}</li>
{{/each}}
</ul>
<h2>{{title}}</h2>
<ul>
{{#each people as |person|}}
{{!-- <li>{{person}}</li> --}}
<li {{action onPersonClick person}}>{{person}}</li>
{{/each}}
</ul>
{
"version": "0.15.1",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js",
"ember": "3.4.3",
"ember-template-compiler": "3.4.3",
"ember-testing": "3.4.3"
},
"addons": {
"ember-data": "3.4.2"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment