Skip to content

Instantly share code, notes, and snippets.

@ryanlabouve
Created December 29, 2016 07:33
Show Gist options
  • Select an option

  • Save ryanlabouve/914bbf5db70ca61b7ba57978f2821a47 to your computer and use it in GitHub Desktop.

Select an option

Save ryanlabouve/914bbf5db70ca61b7ba57978f2821a47 to your computer and use it in GitHub Desktop.
Kata 2
import Ember from 'ember';
export default Ember.Controller.extend({
actions: {
getCheckboxValue(val) {
console.log(...arguments);
console.log(val);
},
getInputValue(val) {
console.log(...arguments);
console.log(val);
},
getMousePosition({offsetX, offsetY}) {
console.log(...arguments);
console.log(offsetX, offsetY);
Ember.$('.marker').css({top:offsetY , left: offsetX });
}
}
});
<input type="checkbox"
onchange={{action 'getCheckboxValue' value="target.checked"}}> Yey checkbox
<br><br><br>
<input type="text"
placeholder="Yey input"
onchange={{action 'getInputValue' value="target.value"}}>
<br><br><br>
<div class="box" onclick={{action 'getMousePosition'}}>
Box
<div class="marker">&nbsp;</div>
</div>
<style>
.box {
background: red; color: white; width: 200px; height: 200px;
position: relative; cursor: pointer;
}
.marker {
width: 4px; height: 4px; background: blue;
position: absolute; top: 0; left: 0;
}
</style>
{
"version": "0.10.7",
"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.10.0",
"ember-data": "2.10.0",
"ember-template-compiler": "2.10.0",
"ember-testing": "2.10.0"
},
"addons": {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment