Skip to content

Instantly share code, notes, and snippets.

@tarponjargon
Last active February 10, 2017 22:17
Show Gist options
  • Save tarponjargon/a55f02dae35caeb7cf6a7e9a77112981 to your computer and use it in GitHub Desktop.
Save tarponjargon/a55f02dae35caeb7cf6a7e9a77112981 to your computer and use it in GitHub Desktop.
New Twiddle
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
import Ember from 'ember';
export default Ember.Controller.extend({
queryParams: [
'foo'
],
foo: null,
actions: {
removeItem: function(i) {
alert(`about to remove ${i.toString()}`);
this.foo.removeObject(i.toString());
console.log(this.foo);
},
}
});
import Ember from 'ember';
import config from './config/environment';
const Router = Ember.Router.extend({
location: 'none',
rootURL: config.rootURL
});
Router.map(function() {
this.route('search');
});
export default Router;
import Ember from 'ember';
export default Ember.Route.extend({
beforeModel() {
this.transitionTo('search');
}
});
import Ember from 'ember';
export default Ember.Route.extend({
queryParams: {
foo: { refreshModel: true }
}
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{outlet}}
<br>
<br>
{{link-to 'Click Here' 'search' }}
you have to manually change the url above to:<br>
/search?foo[]=1&foo[]=2&foo[]=3<br><br>
<b>OUTPUT</b>
foo array contains: {{foo}}<br><br>
Click one to remove from array:<br>
(then note strange QP format change on url - how can ember retain the parameter-array format?)<br><br>
{{#each foo as |f|}}
delete <a href="#" {{action "removeItem" f}}>{{f}}</a><br>
{{/each}}
{{outlet}}
{
"version": "0.11.0",
"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.10.2",
"ember-data": "2.11.0",
"ember-template-compiler": "2.10.2",
"ember-testing": "2.10.2"
},
"addons": {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment