Last active
April 24, 2017 12:32
-
-
Save mrVanboy/6a4ac34aa0641a7a6641d425921f64c8 to your computer and use it in GitHub Desktop.
test destroying
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
let Prvek = Ember.Object.extend({ | |
title: "I am prverk", | |
init(){ | |
let pole = this.constructor.pole; | |
this.set('id',pole.length > 0 ? pole[pole.length-1].id + 1 : 0); | |
this.constructor.pole.pushObject(this); | |
}, | |
willDestroy(){ | |
//this.constructor.runDeleteCallback(this); | |
// console.log(`Destroing element with id ${this.get('id')}`); | |
let pole = this.constructor.pole; | |
let index = pole.indexOf(this); | |
pole.splice(index,1); | |
} | |
}); | |
// statická metoda jednotná pro celou třidu a všechny instance | |
Prvek.reopenClass({ | |
pole: [] | |
}); | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle', | |
pole: Prvek.pole, | |
init(){ | |
this._super(...arguments); | |
Prvek.create(); | |
Prvek.create(); | |
Prvek.create(); | |
/* | |
Prvek.deleteCallback((item)=>{ | |
let pole = this.get('pole'); | |
let index = pole.indexOf(item); | |
pole.splice(index,1); | |
this.notifyPropertyChange('pole'); | |
}); | |
*/ | |
}, | |
actions: { | |
delete(item){ | |
item.destroy(); | |
this.notifyPropertyChange('pole'); | |
// console.log('Pole prvku:', this.get('pole')); | |
}, | |
add(){ | |
Prvek.create(); | |
} | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0.12.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.12.0", | |
"ember-template-compiler": "2.12.0", | |
"ember-testing": "2.12.0" | |
}, | |
"addons": { | |
"ember-data": "2.12.1" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment