Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save quincyle/4bb8cabf7baaa3ae987e8ffec660dfc2 to your computer and use it in GitHub Desktop.
Save quincyle/4bb8cabf7baaa3ae987e8ffec660dfc2 to your computer and use it in GitHub Desktop.
New Twiddle
import Ember from 'ember';
export default Ember.Controller.extend({
queryParams: ['activeSorting'],
//activeSorting: 'hello',
// activeSoring: [],
activeSorting: {},
actions: {
clickHandler() {
let result =[{name: 'q'}, {value: 'a'}]
let result2 = {name: '11'}
this.set('activeSorting', result2)
},
resetHandler() {
//this.set('activeSorting', '')
// this.set('activeSorting', [])
this.set('activeSorting', {})
}
}
});
import Ember from 'ember';
export default Ember.Route.extend({
model: function (params) {
console.log(params)
},
serializeQueryParam(value, urlKey, defaultValueType)
{
// urlKey isn't used here, but anyone overriding
// can use it to provide serialization specific
// to a certain query param.
if (defaultValueType === 'array') {
return JSON.stringify(value);
}
// only type array will trigger Json.stringify by default.
if (defaultValueType === 'null') {
return JSON.stringify(value)
}
if (defaultValueType === 'object') {
return JSON.stringify(value)
}
return '' + value;
},
});
<button {{action (action 'clickHandler')}}>set qp</button>
<button {{action (action 'resetHandler')}}>reset</button>
{
"version": "0.10.5",
"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.8.0",
"ember-data": "2.8.0",
"ember-template-compiler": "2.8.0",
"ember-testing": "2.8.0"
},
"addons": {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment