Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save olenderhub/3bd8e33226faa6d1894fadf6886f8e42 to your computer and use it in GitHub Desktop.
Save olenderhub/3bd8e33226faa6d1894fadf6886f8e42 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);
},
}
});
import Ember from 'ember';
export default Ember.Component.extend({
linkService: Ember.inject.service('link'),
actions: {
setName(name) {
this.sendAction('action', name);
},
bubbleSetName(name) {
this.bubble('setName', name);
},
linkSetName(name) {
this.get('linkService').linkName('link new text');
}
}
});
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.get('linkService').linkName(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 action="setName"}}
{{#2-component-other-method as |x|}}
{{#x.third as |x|}}
{{#x.fourth as |x|}}
{{x.fifth setName=(action "setName")}}
{{/x.fourth}}
{{/x.third}}
{{/2-component-other-method}}
</div>
<div class="second-component">
gray second component (other method)
{{yield (hash third=(component "3-component-other-method"))}}
</div>
<div class="second-component">
gray second component
{{3-component action="setName"}}
</div>
<div class="third-component">
blue third component (other method)
{{yield (hash fourth=(component "4-component-other-method"))}}
</div>
<div class="third-component">
blue third component
{{4-component action="setName"}}
</div>
<div class="fourth-component">
green fourth component (other method)
{{yield (hash fifth=(component "5-component-other-method"))}}
</div>
<div class="fourth-component">
green fourth component
{{5-component action="setName"}}
</div>
<div class="fifth-component">
violet fifth component (other method)
<br>
<button {{action "setName" "other text"}}>button other in fifth component</button>
</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