Native <input type="checkbox">
in <form>
post
passes only checked items as string "on". Unchecked items data is lost. It is impossible to uncheck something!
This plugin will pass data for each checkbox as string "true" or "false"
CSS <style>
tag is injected into <head>
it can be overriden by user <style>
set in <body>
with !important;
directive
global CSS class name used: alfa-checkbox
see example with overriden styles.
attach class name to <input>
checkbox tag
<input type="checkbox" class="alfa-checkbox" name="nameOfDataField" />
NOTE:
unique name
property is required! (needed for posting <form>
data and to associate <Label>
)
id
is set by code id=name
$(document).ready(function () {
// initialize all checkboxes
$.alfaCheckbox('.alfa-checkbox', {
// optional callback function example:
onChange: function () { formDirty = true; $('button[type=submit]').show(); }
});
// to set value of checkbox programmatically:
$.alfaCheckbox('#id', {set:true});
});
see html example how to use.