Skip to content

Instantly share code, notes, and snippets.

@andreiciceu
Last active March 20, 2017 10:15
Show Gist options
  • Save andreiciceu/6d4ef822384a06a252cdd55272d25a58 to your computer and use it in GitHub Desktop.
Save andreiciceu/6d4ef822384a06a252cdd55272d25a58 to your computer and use it in GitHub Desktop.
ember-demo-inherit
import Ember from 'ember';
export default Ember.Component.extend({
submitDone: false,
tagName: '',
actions: {
modalSubmit() {
this.set('submitDone', true);
let f = this.get('submit');
//TODO: if f is function
f();
}
}
});
import Ember from 'ember';
export default Ember.Component.extend({
actions: {
doSubmitClick() {
let f = this.get('okClick')();
f();
}
}
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
actions: {
showSuccess() {
alert('success');
}
}
});
{{!-- Not working
When clicking the Ok button in base-modal, the following should happend
base-modal.actions.doSubmitClick gets called; which in turn calls
app-modal.actions.modalSubmit; (provided via (action '') helper in HBS) which then calls
application.actions.showSuccess (provided via (action '') helper in HBS)
if app-modal.tagName='' is removed/commented, this works as expected
--}}
{{#app-modal submit=(action 'showSuccess')}}
Content
{{/app-modal}}
{{#if submitDone}}
Submitted
{{/if}}
{{#base-modal okClick=(action 'modalSubmit') }}
Content
{{/base-modal}}
<div class="modal">
<div class="body">
{{yield}}
</div>
<div calss="footer">
<button {{action 'doSubmitClick'}}>OK</button>
</div>
</div>
import Ember from 'ember';
export default function destroyApp(application) {
Ember.run(application, 'destroy');
}
import Resolver from '../../resolver';
import config from '../../config/environment';
const resolver = Resolver.create();
resolver.namespace = {
modulePrefix: config.modulePrefix,
podModulePrefix: config.podModulePrefix
};
export default resolver;
import Ember from 'ember';
import Application from '../../app';
import config from '../../config/environment';
const { run } = Ember;
const assign = Ember.assign || Ember.merge;
export default function startApp(attrs) {
let application;
let attributes = assign({rootElement: "#test-root"}, config.APP);
attributes = assign(attributes, attrs); // use defaults, but you can override;
run(() => {
application = Application.create(attributes);
application.setupForTesting();
application.injectTestHelpers();
});
return application;
}
import resolver from './helpers/resolver';
import {
setResolver
} from 'ember-qunit';
setResolver(resolver);
{
"version": "0.11.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.11.0",
"ember-data": "2.11.0",
"ember-template-compiler": "2.11.0",
"ember-testing": "2.11.0"
},
"addons": {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment