Dropdown

Easily create dropdown views for menus, inline editing, or just a simple tooltip.

Click Me

Overview

Version 1.0.0

Dropdown is designed to be robust and extensible. It can be used independently or embedded into another plugin such as List Controller.

The general idea is to display a view inline with the target element. A Backbone.View, jQuery/HTML String, or Array are all acceptable types of "views". An array will be converted into a DropdownMenuView.


General Use

Vanilla

new Dropdown({
    
    // required
    renderTo: $("#my-button"),
    view: null,
    
    // options
    w: 200,
    trigger: 'click',
    align: 'bottomRight',
    autoCenter: false,
    theme: 'default',
    closeOnEsc: true,
    delay: 1000
});

jQuery

// jQuery
$("#my-button").dropdown(view, opts);

Menu Array

This is the most powerful view in Dropdown with many different features such as nesting, dividers, filtering, icons, multiple action events, and more. See the options documentation for details.

Open Menu

$('#menu').dropdown([
    { divider: 'My Menu'},
    { label:'Item 1', val: 1 },
    { label:'Item 2', val: 2 },
    { label:'Item 3', val: 3 },
    'divider',
    { label:'Item 4', val: 4 },
], {
    w:120,
    align: 'bottom',
    onClick: function(item){
        console.log(item)
    }
})

Backbone View Backbone.View

Dropdown can be used as a thin display wrapper for any Backbone view. Once the view has been initialized, pass it to dropdown as the view

My Account


var MyAccount = Backbone.View.extend({
    
    attributes:{style: 'padding: .5em 1em;'},
    
    render: function(){
        this.$el.html('<h2>My Account</h2><p>This is a backbone view loaded inside of a dropdown.<br><br>
            <a class="dd">Click here</a> to see a nested dropdown view</p>');
        this.$('a').dropdown("A nested dropdown. You can have multiple nested dropdowns.
        But dont't get too crazy or your users may not be very happy ;)");
        return this;
    }
}) 

var myAccount = new MyAccount();

$('#myaccount').dropdown(myAccount, {w: 300})

Each time the dropdown is opened, myAccount.render() will be called.


Text Tooltip String/jQuery

Dropdown can also be used as a simple tooltip.

$('#simple-tooltip').dropdown('This is a tooltip', {
    align: 'topRight', 
    trigger: 'hover'
});

This tooltip will be dynamically generated each time it opens.

$('#simple-tooltip-dynamic').dropdown(function(){
    return 'This is dynamic: '+(new Date).toString();
}, {
    align: 'top',
    w: 220, 
    trigger: 'hover'
});

Options

Soon.


License

MIT © Kevin Jantzer


Built by Kevin Jantzer, Blackstone Audio Inc.