Skip to content

Instantly share code, notes, and snippets.

@mjuniper
Last active October 16, 2019 18:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mjuniper/2467d721e0f1e61caa985a4279471263 to your computer and use it in GitHub Desktop.
Save mjuniper/2467d721e0f1e61caa985a4279471263 to your computer and use it in GitHub Desktop.
a-tel ideas
import Ember from 'ember';
export default Ember.Component.extend({
tagName: '',
actions: {
onClick () {
Ember.tryInvoke(this, 'onClickAction');
alert('log telemetry here!');
}
}
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
actions: {
onClick() {
alert('yay');
}
}
});
import EmberRouter from '@ember/routing/router';
import config from './config/environment';
const Router = EmberRouter.extend({
location: 'none',
rootURL: config.rootURL
});
Router.map(function() {
this.route('foo');
});
export default Router;
import Ember from 'ember';
export default Ember.Route.extend({
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{#my-component onClickAction=(action "onClick")}}
this renders a button
{{/my-component}}
<br>
{{#my-component routeName="foo" routeParams="???"}}
this renders a link-to
{{/my-component}}
<br>
{{#my-component href="https://google.com"}}
this renders an anchor tag
{{/my-component}}
{{#if @onClickAction}}
<button {{action "onClick"}}>
{{yield}}
</button>
{{else if @routeName}}
{{!-- NOTE: ember-link-action allows invokeAction to work
this addon is included in opendata-ui --}}
{{#link-to @routeName invokeAction=(action "onClick")}}
{{yield}}
{{/link-to}}
{{else if @href}}
<a href={{@href}} target="_blank" {{action "onClick"}}>
{{yield}}
</a>
{{/if}}
{
"version": "0.15.1",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js",
"ember": "3.4.3",
"ember-template-compiler": "3.4.3",
"ember-testing": "3.4.3"
},
"addons": {
"ember-data": "3.4.2",
"ember-link-action": "1.0.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment