Skip to content

Instantly share code, notes, and snippets.

@ryanlabouve
Last active August 10, 2016 14:54
Show Gist options
  • Select an option

  • Save ryanlabouve/21b6eed93d315ea10a46f6948e9d0564 to your computer and use it in GitHub Desktop.

Select an option

Save ryanlabouve/21b6eed93d315ea10a46f6948e9d0564 to your computer and use it in GitHub Desktop.
New Twiddle
import Ember from 'ember';
export default Ember.Controller.extend({
log(msg) {
Ember.$('.log').append(msg);
Ember.$('.log').append(Ember.$("<br><br>"));
},
writeObject(arg) {
let str = "";
for (let key in arg) {
console.log(key);
str += `${key}: ${arg[key]}`;
}
this.log(str);
},
actions: {
firstAction() {
this.log(`${[...arguments].length} argument(s)`);
[...arguments].forEach(argument => this.writeObject(argument));
}
}
});
body {
margin: 12px 16px;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 12pt;
}
label {
display: block;
line-height: 14px;
padding: 0.3rem;
margin-bottom: 0.7em;
}
input {
height: 32px;
width: 100%;
}
.log {
background: #eee;
color: #333;
padding: 2rem;
margin-top: 3rem;
position: relative;
}
.log:before {
position: absolute;
top: 10px;
left: 10px;
font-size: 12px;
font-weight: bold;
content: 'Results';
}
<h1>Ember Action Koans PT. 1</h1>
<label>onchange=\{{action 'firstAction'}}</label>
<input
placeholder="make a change on this input"
type="text"
onchange={{action 'firstAction'}} />
<div class="log"></div>
{
"version": "0.10.4",
"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.7.0",
"ember-data": "2.7.0",
"ember-template-compiler": "2.7.0"
},
"addons": {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment