Skip to content

Instantly share code, notes, and snippets.

@initram
Last active October 2, 2016 17:06
Show Gist options
  • Save initram/9ce5aa66ba8908046044ac5dd7b68961 to your computer and use it in GitHub Desktop.
Save initram/9ce5aa66ba8908046044ac5dd7b68961 to your computer and use it in GitHub Desktop.
New Twiddle
import Ember from 'ember';
import myTemplate from '../templates/suggestion-template'
export default Ember.Controller.extend({
suggestionTemplate: myTemplate,
suggestSource: function(query, syncResults, asyncResults) {
if(query == 'test')
syncResults([{id: 2, text: "testing is fun!"}]);
else
syncResults([{id: 1, text: "test"}]);
},
getDisplayString : function(suggestion) {
if(typeof suggestion === "string")
return suggestion;
return suggestion.text;
},
updateValue: function(newValue){
this.set('searchInput', getDisplayString(newValue))
}
});
{{aupac-typeahead
action=(action updateValue)
class='form-control'
source=suggestSource
placeholder='Search...'
allowFreeInput=true
display=getDisplayString
transformSelection=getDisplayString
suggestionTemplate=suggestionTemplate
}}
{{outlet}}
{
"version": "0.10.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.6.0",
"ember-data": "2.6.1",
"ember-template-compiler": "2.6.0"
},
"addons": {
"ember-aupac-typeahead": "2.0.7"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment