Skip to content

Instantly share code, notes, and snippets.

@nolaneo
Created January 18, 2018 17:19
Show Gist options
  • Save nolaneo/acf2cf3a484fe6097ebcb341065b5ec1 to your computer and use it in GitHub Desktop.
Save nolaneo/acf2cf3a484fe6097ebcb341065b5ec1 to your computer and use it in GitHub Desktop.
New Twiddle
import Ember from 'ember';
export default Ember.Component.extend({
didInsertElement() {
Ember.$(document).on('click.' + this.get('elementId'), Em.run.bind(this, () => {
this.get('close')();
console.error('I CLOSED MYSELF!');
}));
},
willDestroyElement() {
Ember.$(document).off('click.' + this.get('elementId'));
}
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
open: false,
actions: {
open() {
this.set('open', true);
},
close() {
this.set('open', false);
}
}
});
<h1>Opened? [{{open}}]</h1>
<a href="" {{action "open"}}>
Open the component with the click listener
</a>
{{#if open}}
{{my-component close=(action 'close')}}
{{/if}}
{
"version": "0.13.0",
"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.16.2",
"ember-template-compiler": "2.16.2",
"ember-testing": "2.16.2"
},
"addons": {
"ember-data": "2.16.3"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment