Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kumkanillam/c6c9a0e80ad99d79434f016080645483 to your computer and use it in GitHub Desktop.
Save kumkanillam/c6c9a0e80ad99d79434f016080645483 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: [
'q',
'paging',
'search_page',
'search_title',
'sort',
'search_sort',
'category_code',
'bct',
'filter_breadcrumb',
'filter_price',
'filter_size_apparel',
'filter_size_jewelry',
'filter_metal_type',
'filter_color',
'filter_county'
],
q: null,
paging: 18,
sort: 'best',
search_sort: 'relevance',
search_title: null,
bct: null,
category_code: null,
search_page: null,
filter_breadcrumb: null,
filter_price: null,
filter_size_apparel: null,
filter_size_jewelry: null,
filter_metal_type: null,
filter_color: null,
filter_county: null,
actions: {
deleteStuff(key) {
if(Ember.isEqual(key,'q')){
this.set('q',null);
}
/*
let urlData = this;
alert("deleteStuff called with " + key);
delete urlData[key];
urlData.notifyPropertyChange();
let newData = {};
console.log(urlData);
urlData.queryParams.forEach(function (param) {
if (Ember.get(urlData, param)) {
newData[param] = Ember.get(urlData, param);
console.log(`${param}`);
}
});
this.transitionToRoute('results', { queryParams: newData });
*/
}
}
});
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({
queryParams: { q:{ refreshModel: true }}
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{outlet}}
<br>
<br>
{{link-to 'Click Here' 'search' (query-params q="shirt" search_page="3" filter_breadcrumb="Category > Subcategory")}}
here are the controller properties (click one of the top 3 to remove from the controller properties)<br>
I am kind of expecting the QP to reflect the key deletion but it's not happening
<br>
{{#each-in this as |key value|}}
<a href="#" {{action "deleteStuff" key}}>{{key}}: {{value}}</a><br>
{{/each-in}}
<br><br>
(side question: in a template, how do you iterate over *just* the controller properties and not the functions?)
{
"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