ejmCheckBox
5 Jun 20239 minutes to read
The Essential JavaScript Mobile widget for CheckBox element allows you to check an option or multiple options to perform an action, within your webpage and allows you to specify an option from the list.
Custom Design for Html CheckBox control.
Custom Design for HTML CheckBox control.
$(element).ejmCheckBox()
Example
<!-- Obtrusive way of rendering -->
<input type="checkbox" id="chkbox" />
<script>
$("#chkbox").ejmCheckBox();
</script>
Requires
-
module:jQuery
-
module:ej.core
-
module:ej.unobtrusive
-
module:ej.mobile.core
-
module:ej.data
-
module:ej.touch
checked Boolean
Specifies whether to check the control.
Default Value:
- false
Example
<!-- Unobtrusive way of rendering -->
<input type="checkbox" id="chkbox" data-role="ejmcheckbox" data-ej-checked=true />
<!-- Obtrusive way of rendering -->
<input type="checkbox" id="chkbox" />
<script>
$("#chkbox").ejmCheckBox({ checked: true });
</script>
cssClass String
Sets the root class for CheckBox theme. This cssClass API helps to use custom skinning option for CheckBox control. By defining the root class using this API, we need to include this root class in CSS.
Default Value:
- ””
Example
<!-- Unobtrusive way of rendering -->
<input type="checkbox" id="chkbox" data-role="ejmcheckbox" data-ej-cssclass="customclass" />
<!-- Obtrusive way of rendering -->
<input type="checkbox" id="chkbox" />
<script>
// To set cssClass API value
$("#chkbox").ejmCheckBox({ cssClass: "customclass" });
</script>
enabled Boolean
Specifies whether to enable or disable the control.
Default Value:
- true
Example
<!-- Unobtrusive way of rendering -->
<input type="checkbox" id="chkbox" data-role="ejmcheckbox" data-ej-enabled=false />
<!-- Obtrusive way of rendering -->
<input type="checkbox" id="chkbox" />
<script>
// To set enabled API value
$("#chkbox").ejmCheckBox({ enabled: false });
</script>
enablePersistence Boolean
Specifies to maintain the current model value to browser cookies for state maintenance. While refresh the page, the model value will get apply to the control from browser cookies.
Default Value:
- false
Example
<!-- Unobtrusive way of rendering -->
<input type="checkbox" id="chkbox" data-role="ejmcheckbox" data-ej-enablepersistence=true />
<!-- Obtrusive way of rendering -->
<input type="checkbox" id="chkbox" />
<script>
$("#chkbox").ejmCheckBox({ enablePersistence: true });
</script>
enableRippleEffect Boolean
Specifies the ripple effect for the CheckBox control. By default in android mode its value is true and other rendermode we need to set as true.
Default Value:
- ej.isAndroid()?true:false
Example
<!-- Unobtrusive way of rendering -->
<input type="checkbox" id="chkbox" data-role="ejmcheckbox" data-ej-enablerippleeffect=true />
<!-- Obtrusive way of rendering -->
<input type="checkbox" id="chkbox" />
<script>
$("#chkbox").ejmCheckBox({ enableRippleEffect: true });
</script>
renderMode enum
Specifies the rendering mode of the control.SeeRenderMode
Default Value:
- auto
Example
<!-- Unobtrusive way of rendering -->
<input type="checkbox" id="chkbox" data-role="ejmcheckbox" data-ej-rendermode="auto" />
<!-- Obtrusive way of rendering -->
<input type="checkbox" id="chkbox" />
<script>
// To set renderMode API value
$("#chkbox").ejmCheckBox({ renderMode: ej.mobile.RenderMode.Auto });
</script>
Methods
disable()
To disable the CheckBox.
Example
<input type="checkbox" id="chkbox" />
<script>
// get the CheckBox current state
$("#chkbox").ejmCheckBox();
$("#chkbox").ejmCheckBox("disable");
</script>
enable()
To enable the CheckBox.
Example
<input type="checkbox" id="chkbox" />
<script>
$("#chkbox").ejmCheckBox();
$("#chkbox").ejmCheckBox("enable");
</script>
isChecked()
To check whether the CheckBox is checked or not.
Example
<input type="checkbox" id="chkbox" />
<script>
// get the CheckBox current state
$("#chkbox").ejmCheckBox();
$("#chkbox").ejmCheckBox("isChecked");
</script>
Events
beforeChange
Event triggers before the CheckBox state is changed.
Name | Type | Description | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
argument | Object |
Event parameters from CheckBox.
|
Example
<!-- Unobtrusive way of rendering -->
<input type="checkbox" id="chkbox" data-role="ejmcheckbox" data-ej-beforechange="onBeforeChange" />
<script>
// before change event for CheckBox
function onBeforeChange(args) {
//handle the event
}
</script>
<!-- Obtrusive way of rendering -->
<input type="checkbox" id="chkbox" data-role="ejmcheckbox" />
// before change event for CheckBox
<script>
$("#chkbox").ejmCheckBox({
beforeChange: function (args) {
//handle the event
}
});
</script>
change
Event triggers when the CheckBox state is changed.
Name | Type | Description | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
argument | Object |
Event parameters from CheckBox.
|
Example
<!-- Unobtrusive way of rendering -->
<input type="checkbox" id="chkbox" data-role="ejmcheckbox" data-ej-change="onChange" />
<script>
// change event for CheckBox
function onChange(args) {
//handle the event
}
</script>
<!-- Obtrusive way of rendering -->
<input type="checkbox" id="chkbox" data-role="ejmcheckbox" />
// change event for CheckBox
<script>
$("#chkbox").ejmCheckBox({
change: function (args) {
//handle the event
}
});
</script>
touchEnd
Event triggers when touch end happens on the control.
Name | Type | Description | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
argument | Object |
Event parameters from CheckBox.
|
Example
<!-- Unobtrusive way of rendering -->
<input type="checkbox" id="chkbox" data-role="ejmcheckbox" data-ej-touchend="touchEnd" />
<script>
// touchEnd event for CheckBox
function touchEnd(args) {
//handle the event
}
</script>
<!-- Obtrusive way of rendering -->
<input type="checkbox" id="chkbox" data-role="ejmcheckbox" />
// touchEnd event for CheckBox
<script>
$("#chkbox").ejmCheckBox({
touchEnd: function (args) {
//handle the event
}
});
</script>
touchStart
Event triggers when touch start happens on the control.
Name | Type | Description | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
argument | Object |
Event parameters from CheckBox.
|
Example
<!-- Unobtrusive way of rendering -->
<input type="checkbox" id="chkbox" data-role="ejmcheckbox" data-ej-touchstart="touchStart" />
<script>
// touchStart event for CheckBox
function touchStart(args) {
//handle the event
}
</script>
<!-- Obtrusive way of rendering -->
<input type="checkbox" id="chkbox" data-role="ejmcheckbox" />
// touchStart event for CheckBox
<script>
$("#chkbox").ejmCheckBox({
touchStart: function (args) {
//handle the event
}
});
</script>