Skip to content

Instantly share code, notes, and snippets.

@rossjha
Last active June 9, 2022 15:30
Show Gist options
  • Save rossjha/188b7cba2bbcfb91df9413c393591044 to your computer and use it in GitHub Desktop.
Save rossjha/188b7cba2bbcfb91df9413c393591044 to your computer and use it in GitHub Desktop.
New Twiddle
import Component from '@ember/component';
import { run } from '@ember/runloop';
import { get, set } from "@ember/object"
export default Component.extend({
isEditing: true,
actions: {
save() {
this.doSave?.()
run(this, () => {
set(this, 'isEditing', false);
})
}
}
});
import Controller from '@ember/controller';
export default Controller.extend({
actions: {
saveAttr() {
console.log('save attr');
}
}
});
{{#my-component doSave=(action "saveAttr") as |foo|}}
<div>{{if foo.isEditing "true"}}</div>
<button onclick={{action foo.doSave}}>Save</button>
{{/my-component}}
{{yield (hash isEditing=isEditing doSave=(action "save"))}}
{
"version": "0.17.1",
"EmberENV": {
"FEATURES": {},
"_TEMPLATE_ONLY_GLIMMER_COMPONENTS": false,
"_APPLICATION_TEMPLATE_WRAPPER": true,
"_JQUERY_INTEGRATION": true
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.js",
"ember": "2.18.2",
"ember-template-compiler": "2.18.2",
"ember-testing": "2.18.2"
},
"addons": {
"@glimmer/component": "1.0.0",
"ember-data": "2.18.5"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment