Socket
Socket
Sign inDemoInstall

mithchosen

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mithchosen

a simple implementation of a list chooser with a search and sort capability. Intended to be used as a component for mithril js.


Version published
Maintainers
1
Created
Source

mithChosen

This code is a simple implementation of a list chooser with a search and sort capability. Intended to be used as a component for mithril js. It includes methods to update the list on the fly and also set style in the config file. Made for mithril it intends to give a similar functionality to of the chosen plugin made for jquery.

For an example visit the jsFiddle link below or use the example provided in the repository. to use the component simple add the code in the lib to your js file either by require or using it directly and add it as a component in the main view of the mounted object. see below for more info

Live od jsFiddle Live on GitHub.io Usage:

Create an instance with a config:

var config = {
    list: [], //the list
   
    itemsPerPage: 10, //number of items shown in the list
    sortByName: true, //sort
    styles: { 
		width: "200px", //width of the list
        selectedBackground: 'black', 
        selectedForeground: 'white',
        background: 'white',
        foreground: 'black'
    }
};

var chosen = new MithChosen(config);
// The list may be updated at any time using the update() method.

chosen.update(['Tabriz', 'Istanbul','Karachi',
				    'Shanghai','Mumbai','Newyork',
				    'London','Adelaide','HongKong',
				    'Chicago','Baku','Cairo',
				    'Baghdad','Nairobi','Mexico']);
					
// or it can be provided when instantiating.

Add the component to your main view using mithrils m.component utilty and mount that object to the DOM.

var main = {
	view: function(){
		return m.component(chosen)
	}
}
m.mount(document.body,main);

Keywords

FAQs

Package last updated on 23 Apr 2016

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc