Skip to content

Instantly share code, notes, and snippets.

@lovelykaushik86
Last active February 6, 2016 10:24
Show Gist options
  • Save lovelykaushik86/5f8447dfc8a858aebf6a to your computer and use it in GitHub Desktop.
Save lovelykaushik86/5f8447dfc8a858aebf6a to your computer and use it in GitHub Desktop.
New Twiddle
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Jumping Balls',
jumpingBalls: [{"newBall": true}],
ball: {"newBall": true},
actions: {
}
});
<h1>Welcome to {{appName}}</h1>
<br>
{{jumping-balls jumpingBalls = jumpingBalls }}
{{outlet}}
<br>
<br>
import Ember from 'ember';
export default Ember.Component.extend({
didInsertElement: function () {
var that = this;
// setInterval(function(){
// that.send("addBalls");
//}, 5000);
},
init: function () {
var tmp = '<div style="cursor:pointer" {{action "addBalls"}}>Add new balls</div><br/><div class="canvas">{{#each jumpingBalls as |ball|}}<div class="ball"></div><br/>{{/each}}</div>';
this.set('layout', Ember.Handlebars.compile(tmp));
this._super();
},
actions: {
addBalls: function () {
for (var i = 0; i < 5; i++) {
this.get("jumpingBalls").pushObject("");
}
}
}
});
body {
margin: 12px 16px;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 12pt;
}
.canvas {
border: 1px solid black;
width:100%;
height:300px;
overflow:auto;
}
.ball {
border:thin solid black;
width:25px;
height:25px;
border-radius:66%;
background:orange;
}
{
"version": "0.5.0",
"EmberENV": {
"FEATURES": {}
},
"options": {
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.2.0/ember.debug.js",
"ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/2.2.0/ember-data.js",
"ember-template-compiler": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.2.0/ember-template-compiler.js"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment