mit

mithchosen

A simple select list with search implemented for mithril.js

Showing:

Popularity

Downloads/wk

3

GitHub Stars

9

Maintenance

Last Commit

6yrs ago

Contributors

1

Package

Dependencies

0

License

ISC

Type Definitions

Tree-Shakeable

No?

Categories

Readme

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);

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100
No reviews found
Be the first to rate

Alternatives

No alternatives found

Tutorials

No tutorials found
Add a tutorial