Options albhilazo.checklist

by Albert Hilazo

HTML

<link rel="stylesheet" href="https://rawgit.com/albhilazo/checklist/master/albhilazo.checklist.css">
<script src="https://rawgit.com/albhilazo/checklist/master/albhilazo.checklist.js"></script>
<div id='container-default'>Content will be appended by default</div>
<br>
<br>
<div id='container-placement'>This will be replaced</div>
<br>
<br>
<div id='container-checked'>
    <div class='checked-specified'></div>
    <div class='checked-mixed'></div>
</div>
<br>
<br>
<div id='container-sizes'></div>
<br>
<br>
<div id='container-onchange'></div>
<br>
<br>
<div id='container-trigger'></div>
<br>
<br>
<div id='container-links'></div>
<br>
<br>
<div id='container-labels'></div>

JavaScript

/* Default use */
$('#container-default').albhilazo_checklist({
    items: ["This is a simple", "checklist plugin", "and this example uses", "just its default settings"]
});


/* Placement */
$('#container-placement').albhilazo_checklist({
    items: ["Replace", "Prepend", "Append"],
    placement: 'replace',
    labelNone: 'Replace or prepend the content'
});


/* Checked/Unchecked */
$('#container-checked .checked-specified').albhilazo_checklist({
    items: [["Specify",true], ["using",false], ["two-dimensional",true], ["arrays",false]],
    labelFiltered: 'Load some checked'
});
$('#container-checked .checked-mixed').albhilazo_checklist({
    items: ["true = checked", "false = unchecked", ["Or specify just one",false]],
    checked: true,
    labelFiltered: 'Change default status'
});


/* Specific sizes */
$('#container-sizes').albhilazo_checklist({
    items: ["Width", "Height", "Width only affects the label, not the list", "Height affects the list's scroll"],
    width: '200px',
    height: '60px',
    labelNone: 'Fixed width and max-height'
});


/* onChange Callback */
$('#container-onchange').albhilazo_checklist({
    items: ["Checking or unchecking", "an item will call", "onChange function with", "given onChangeParams"],
    onChange: function(e, $chlist, onChangeParams) {
        // Example of how to retrieve checked items
        var checked = '';
        $chlist.find('input:checked').each(function(i,input){
            if (i>0)    checked += ', ';
            checked += $(input).parent().text();
        });
        
        var alertText = 'Checked: '+checked+'\n'
                        +'Params: '+onChangeParams.param1+' '+onChangeParams.param2;
        alert(alertText);
    },
    onChangeParams: {param1:'This plugin', param2:'is awesome!'},
    labelNone: 'Callback on check/uncheck'
});


/* Trigger */
$('#container-trigger').albhilazo_checklist({
    items: ["hover", "click"],
    trigger: 'click',
    labelNone: 'Click me!'
});


/* Links...