Skip to content

Instantly share code, notes, and snippets.

@hvgotcodes
Last active August 9, 2016 20:53
Show Gist options
  • Save hvgotcodes/8b293cc7aef1706b45d442b2fab3c7fc to your computer and use it in GitHub Desktop.
Save hvgotcodes/8b293cc7aef1706b45d442b2fab3c7fc to your computer and use it in GitHub Desktop.
ModalsAreDifficult
import Ember from 'ember';
export default Ember.Component.extend({
});
import Ember from 'ember';
export default Ember.Component.extend({
classNames: ['modal'],
actions: {
closeModal() {
this.$().removeClass('visible');
}
}
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
actions: {
openModal() {
Ember.$('.modal').addClass('visible');
}
}
});
body {
margin: 12px 16px;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 12pt;
}
.modal {
display: none;
}
.modal.visible {
display:block;
}
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{outlet}}
<br>
<br>
<button type="button" {{action "openModal"}}>Open Modal</button>
{{my-modal}}
<h2>I am a modal</h2>
{{my-form}}
<button type="button" {{action "closeModal"}}>Close me</button>
{
"version": "0.10.4",
"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.7.0",
"ember-data": "2.7.0",
"ember-template-compiler": "2.7.0"
},
"addons": {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment