Last active
January 18, 2016 20:04
-
-
Save ohcibi/321e6c1e40f3e73c4357 to your computer and use it in GitHub Desktop.
New Twiddle
This file contains 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'; | |
export default Ember.Controller.extend({ | |
actions: { | |
foo() { | |
alert("called"); | |
} | |
}, | |
selection: [], | |
appName:'Ember Twiddle' | |
}); |
This file contains 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.5.0", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"ember": "2.2.0", | |
"ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/2.2.0/ember-data.js", | |
"ember-template-compiler": "2.2.0" | |
} | |
} |
This file contains 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 i = 0; | |
const computed = Ember.computed; | |
export default Ember.Component.extend({ | |
selected: computed("selection.[]", "modelId", function() { | |
return this.get("selection").contains(this.get("modelId")); | |
}), | |
click(e) { | |
this.get("otherFn")(); | |
this.addOrRemoveFromSelection(); | |
}, | |
addOrRemoveFromSelection() { | |
let selection = this.get("selection"), | |
modelId = this.get("modelId"); | |
if (selection.contains(modelId)) { | |
selection.removeObject(modelId); | |
} else { | |
selection.addObject(modelId); | |
} | |
this.setSelection(selection); | |
}, | |
setSelection(selection) { | |
alert(this.get("selection.update")); | |
if (typeof this.attrs.selection.update === "function") { | |
this.attrs.selection.update(selection); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment