Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save sagelliv/e2d9171494dcc2a1eded490cc86d3fe2 to your computer and use it in GitHub Desktop.
Save sagelliv/e2d9171494dcc2a1eded490cc86d3fe2 to your computer and use it in GitHub Desktop.
New Twiddle
import Ember from 'ember';
export default Ember.Component.extend({
actions: {
setName(name) {
this.sendAction('action', name);
}
}
});
import Ember from 'ember';
export default Ember.Component.extend({
actions: {
setName(name) {
this.sendAction('action', name);
}
}
});
import Ember from 'ember';
export default Ember.Component.extend({
actions: {
setName(name) {
this.sendAction('action', name);
}
}
});
import Ember from 'ember';
export default Ember.Component.extend({
actions: {
setName(name) {
this.sendAction('action', name);
}
}
});
import Ember from 'ember';
export default Ember.Component.extend({
actions: {
setName(name) {
this.get('setName')(name);
},
bubbleSetName(name) {
this.bubble('setName', name);
}
}
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
import Ember from 'ember';
export default Ember.Controller.extend({
linkService: Ember.inject.service('link'),
text: Ember.computed.readOnly('linkService.text'),
actions: {
setName(name) {
this.set('linkService.text', name);
}
}
});
import Ember from 'ember';
import config from './config/environment';
const Router = Ember.Router.extend({
location: 'none',
rootURL: config.rootURL
});
Router.map(function() {
this.route('main', { path: '/' });
});
export default Router;
.main-route {
border: 1px solid red;
margin: 10px;
padding: 10px;
}
.first-component {
border: 1px solid orange;
margin: 10px;
padding: 10px;
}
.second-component {
border: 1px solid gray;
margin: 10px;
padding: 10px;
}
.third-component {
border: 1px solid blue;
margin: 10px;
padding: 10px;
}
.fourth-component {
border: 1px solid green;
margin: 10px;
padding: 10px;
}
.fifth-component {
border: 1px solid violet;
margin: 10px;
padding: 10px;
}
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{outlet}}
<br>
<br>
<div class="first-component">
yellow first component
{{#2-component as |x|}}
{{#x.third as |x|}}
{{#x.fourth as |x|}}
{{x.fifth setName=(action "setName")}}
{{/x.fourth}}
{{/x.third}}
{{/2-component}}
</div>
<div class="second-component">
gray second component
{{yield (hash third=(component "3-component"))}}
</div>
<div class="third-component">
blue third component
{{yield (hash fourth=(component "4-component"))}}
</div>
<div class="fourth-component">
green fourth component
{{yield (hash fifth=(component "5-component"))}}
</div>
<div class="fifth-component">
violet fifth component
<br>
<button {{action "setName" "new text"}}>button normal in fifth component</button>
<button {{action "bubbleSetName" "bubble new text"}}>button bubble in fifth component</button>
<button {{action "linkSetName" "link new text"}}>button link in fifth component</button>
</div>
<div class="main-route">
red main-route-template
{{1-component action="setName"}}
<br>
{{text}}
</div>
{
"version": "0.12.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.12.0",
"ember-template-compiler": "2.12.0",
"ember-testing": "2.12.0"
},
"addons": {
"ember-data": "2.12.1",
"ember-component-action-bubbling": "0.1.3"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment