Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
ember-cli-auto-complete
Advanced tools
ember-cli addon that provides type-ahead selection for text inputs
ember-cli addon that provides type-ahead selection for text inputs (requires ember.js 1.11+)
http://emberjs.jsbin.com/niluhaloke/1
npm install ember-cli-auto-complete --save-dev
First add a custom component that extends AutoComplete. In this component you need to add 2 computed properties and 1 string variable.
1) suggestions: this computed will determine how the list of options is filtered as the user enters text
2) optionsToMatch: this computed will determine if the value entered is valid (when the user omits to click/enter/tab the selection)
3) valueProperty: this string should be the value property for the options passed in (think selectbox value/label)
import AutoComplete from "ember-cli-auto-complete/components/auto-complete";
export default AutoComplete.extend({
valueProperty: "code",
suggestions: function() {
var inputVal = this.get("inputVal") || "";
return this.get("options").filter(function(item) {
return item.get("code").toLowerCase().indexOf(inputVal.toLowerCase()) > -1;
});
}.property("inputVal", "options.@each"),
optionsToMatch: function() {
var caseInsensitiveOptions = [];
this.get("options").forEach(function(item) {
var value = item.get("code");
caseInsensitiveOptions.push(value);
caseInsensitiveOptions.push(value.toLowerCase());
});
return caseInsensitiveOptions;
}.property("options.@each")
});
Next add the component to your template including a block with html for the options (requires ember 1.11)
{{#my-auto-complete options=codes inputClass="foobar" selectedValue=model.code placeHolderText="Find a thing" noMesssagePlaceHolderText="No things are found" as |result|}}
<p><b>{{result.code}}</b>{{result.text}}</p>
{{/my-auto-complete}}
Finally prepare a list of options for the component in the route or controller
var Foo = Ember.Object.extend({});
var Bar = Ember.Object.extend({code: ""});
export default Ember.Route.extend({
model: function() {
var codes = [];
codes.pushObject(Foo.create({code: "ABC", text: "SOMETHING 1"}));
codes.pushObject(Foo.create({code: "ABCD", text: "SOMETHING 2"}));
codes.pushObject(Foo.create({code: "ABCDE", text: "SOMETHING 3"}));
return Ember.RSVP.hash({
model: Bar.create(),
codes: codes
});
},
setupController: function(controller, hash) {
controller.set("model", hash.model);
controller.set("codes", hash.codes);
}
});
If you would like to call an action every time an elements is
selected just bind the action through the attribute selectItem
.
{{#my-auto-complete
options=codes
selectedValue=model.code
placeHolderText="Find a thing"
inputClass="my-fun-input-thing andTwo"
noMesssagePlaceHolderText="No things are found"
selectItem="itemSelected" as |result|}}
<p><b>{{result.code}}</b>{{result.text}}</p>
{{/my-auto-complete}}
<p class="selection">{{controller.selection}}</p>
In the example above the action itemSelected
will be called with the
selected item
, bubbling through your routes and controllers.
actions: {
itemSelected: function(item) {
this.get('controller').set('selection', item.get('code'));
}
}
npm install
bower install
ember test
1) npm install
2) bower install
3) ember server
4) localhost:4200
First I'd like to thank Nick Christus for the design work that made this great component happen to begin with. Next I'd like to thank Charlie for his amazing project ember-cli-suggest as this project truly represents a fork of his work.
Copyright © 2015 Toran Billups http://toranbillups.com
Licensed under the MIT License
FAQs
ember-cli addon that provides type-ahead selection for text inputs
The npm package ember-cli-auto-complete receives a total of 2 weekly downloads. As such, ember-cli-auto-complete popularity was classified as not popular.
We found that ember-cli-auto-complete demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.