vsn4ik / bootstrap-checkbox Goto Github PK
View Code? Open in Web Editor NEWA checkbox component based on Bootstrap framework.
Home Page: https://vsn4ik.github.io/bootstrap-checkbox/
License: MIT License
A checkbox component based on Bootstrap framework.
Home Page: https://vsn4ik.github.io/bootstrap-checkbox/
License: MIT License
Version v1.2.0 seams like it broke the change event.
Now this is not firing when clicking bootstrap-checkbox (it works with 1.1.9)...
$("#MyCheckBox").change(function (e) { alert("changed"); });
When changing the state of the checkbox using jquery script, the checkbox doesn't switch visually.
Look at this code
<input id="chk" type="checkbox") />
$('#chk').checkboxpicker();
$('#chk').prop('checked', false).trigger('change');
You will see the checkbox does not switch/toggle.
Any idea how to fix it?
Cheers,
Bit5
Initializing the bootstrap-checkboxes after loading jquery, bootstrap as shown below.
$(':checkbox').checkboxpicker();
Working Fine in Chrome.
Only in IE Shows Error "Object doesn't support property or method 'checkboxpicker'". Which is an intermittent Issue. Please help me how to fix.
Quick Fix required for the above Issue
Is there any time frame to make the project compitible with latest bootstrap 4 .
I'm sure I'm missing something obvious but I cannot get this to work, all checkboxes show up as checkboxes not switches.
I downloaded the latest version and put the dist folder into my project folder. Then copied the basic html from the examples and added one simple checkbox:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css">
<script src="https://code.jquery.com/jquery-2.2.3.min.js" defer></script>
<script src="dist/js/bootstrap-checkbox.min.js" defer></script>
</head>
<body>
<div class="form-horizontal">
<div class="form-group">
<div class="col-sm-3">
<input type="checkbox">
</div>
</div>
</div>
</body>
</html>
Any help much appreciated, I'd really like to use this!
Pete
When using this checkbox, the checked and unchecked is reversed.
Look at this code
<input id="chk" type="checkbox" checked) />
You will see that the "NO" has been selected. And when you use in the js it is totally wrong! The No will be "TRUE" and Yes will become "FALSE".
$('#chk').checkboxpicker();
$('#chk').change(function () { alert ($(this).is(":checked")); });
$('#chk').prop('checked', false).trigger('change');
Any idea how to fix it?
Cheers
I'm trying to use this script in dynamic created checkboxes.
If I only activate the checkboxes width the call $(':checkbox').checkboxpicker(); the checkboxes don't work. I need to call the function every time I insert a new checkbox. This fix the problem, but now the checkboxes that already exist are duplicated.
Did this to solve the problem.
var Checkboxpicker = function(element, options) {
this.element = element;
/** My fix **/
if (!$(element).is(':visible')){return;}
/** end **/
this.$element = $(element).hide();
this.options = $.extend({}, $.fn.checkboxpicker.defaults, options, this.$element.data());
// .btn-group-justified works with <label> elements as the <button> doesn't pick up the styles
this.$buttons = $('<label></label><label></label>').addClass('btn').click(this.clicked.bind(this));
this.$off = this.$buttons.eq(0).html(this.options.offLabel);
this.$on = this.$buttons.eq(1).html(this.options.onLabel);
this.$group = $('<div class="btn-group"></div>')
.append(this.$buttons)
.keydown(this.keydown.bind(this))
.insertAfter(element);
this.init();
};
Bootstrap puts, in the examples, the input inside the label. Then this error pops up.
<label class="required"><input id="register_financier_practice_association_financier_practice_enabled" name="register_financier_practice_association[financier_practice_enabled]" required="required" value="1" type="checkbox"> Habilitada</label>
I will have to remove it via JavaScript and create separately, because I'm using Symfony Forms component and I found no way to stop it creating Input inside label. Even with label => false, it creates an empty label element.
It looks like a checkbox, converted to a 'checkboxpicker' can still be changed even though it has been set to readonly. The state of the button changes to dimmed (e.g. disabled) but i can still click on it and it updates the state of the checkbox.
Changing this:
click: function(event) {
// Strictly event.currentTarget. Fix #19
var $button = $(event.currentTarget);
if (!$button.hasClass('active') || this.options.switchAlways) {
this.change();
}
}
To this fixed the issue:
click: function(event) {
// Strictly event.currentTarget. Fix #19
var $button = $(event.currentTarget);
if ($button.hasClass('disabled')) {
return;
}
if (!$button.hasClass('active') || this.options.switchAlways) {
this.change();
}
},
Couple of questions.
Is it possible to have neither No nor Yes highlighted on initial display?
Is it possible to set a $_POST value for the off state?
Also, the data-off-icon-cls and data-on-icon-cls don't have any effect. Tried it with the example on the web page for thumbs up and thumbs down.
Thanks,
Pete
hi.
i want get a value after click a checkbox. for example after click a left checkbox return 0 and right return 1
please help me.
The Checkbox Plug isnt respecting the ReadOnly attribute.
I need to use ReadOnly so that the control still postback to the server, because disabled fiedls dont post
It would be nice to have some sort of a boolean option to display checkbox choices reversed like Yes | No
in place of No | Yes
, giving "priority" to the positive choice instead. ๐
In IE 9/10, the checkboxes are still visible above or beside the buttons.
The top right conrner is not rounded because both btn-group
and btn-group-vertical
class are applied:
<div is="0" class="btn-group btn-group-vertical m-b" tabindex="0">
<a is="0" class="btn active btn-danger">No</a>
<a is="1" class="btn btn-default">Yes</a>
</div>
It displays just fine if I remove the btn-group
class from the div:
<div is="0" class="btn-group-vertical m-b" tabindex="0">
<a is="0" class="btn active btn-danger">No</a>
<a is="1" class="btn btn-default">Yes</a>
</div>
Hi, can i use class="le-checkbox" instead id="le-checkbox" on DOM?
Great work!
Is it possible to have an onclick event with these? I want it to run a javascript function when I click on the buttons.
Hello! I love using this great tool. I also use Bootstrap Multiselect. However, when both are initialized on the same page, this plugin throws a warning: "Please do not use Bootstrap-checkbox element in label element." and breaks quite a bit of functionality of the Bootstrap Multiselect. This could be worth investigating and I will let you know what I find.
Hi
I am trying to use this plugin in one of my asp.net view, it shows the Yes/No button perfectly in place of Checkbox.
But when I click the Yes/No button, it throw "undefined" error. Please help.
Let the end user control what the size of the button should be.
Eg. I changed it to small...
this.$buttons = $('').addClass('btn btn-xs');
This should be set in options.
The default behavior for checkboxes is to have the space key toggle the checkbox, and the enter key to submit the form. I noticed that both the space and enter keys toggle the checkbox, which is not consistent with browser behavior.
Any thoughts on this and whether this behavior should be fixed?
Attempting to install bootstrap-checkbox via npm fails with:
/home/dvatp
โโโ [email protected]
โโโ UNMET PEER DEPENDENCY grunt@~0.4.5
npm WARN [email protected] requires a peer of grunt@~0.4.5 but none was installed.
So it's looking for grunt 0.4.5 but that is apparently no longer available in the repository so the dependency can't be satisfied.
This is odd because I checked the source for 1.4.0 and package.json indicates a dependency on a 1.x variant of grunt. Was the package built incorrectly?
<input type="checkbox" data-off-title="No" data-on-title="Yes">
Also be nice if there was a way of controling the size via data attribute. At the moment I have to do this:
$this.checkboxpicker({
defaultClass: 'btn-default btn-sm',
offClass: 'btn-danger btn-sm',
onClass: 'btn-info btn-sm'
});
When checking and unchecking the checkbox, the "input" should be updated with the value.
I would like a feature to disable this addon for specific checkboxes. Something like data-check-disable="true" within the input element would do nicely.
If I do this in code...
$('#MyCheckBox').attr("checked", "checked");
... the buttons still says "Off".
How can I update the bootstrap-checkbox to reflect the "input checkbox"?
Thanks
event.target
== <span>
if the cursor is positioned over <span>
(MouseEvent).
I've ran into an interesting problem. I have found that when rendering the page with AJAX (which is used everywhere today), checkboxes within the newly rendered content still show as a checkbox and not a switch. Rendering can be done by either DOM object manipulation or by direct HTML injection into a DIV tag. I have found that using this code
<!-- Checkbox Boot Script -->
<script type="text/javascript">
function featureCheckbox() {
$(':checkbox').checkboxpicker();
}
</script>
at the bottom of the HTML template page, and then calling the function featureCheckbox()
as the last action in the AJAX response handler, I was able to get it to work. The documentation should be updated to indicate this little caveat.
This is within the AJAX response handler.
// Feature Activations
if (typeof ajaxResponseHandler == typeof featureCheckbox)
{
featureCheckbox();
}
Another thing that I noticed is that all checkboxes must be rendered and on screen before calling the activation routine. Any checkboxes that are rendered after the activation routine will not get the new visual and will remain as an ordinary checkbox. The documentation should be updated to reflect this.
Anyways, this is a nice addon. Good Job!
How do you make it work with Angular.js?? With a directive??
I 've inserted in my form without the label and everything, but the Actual Checkbox with tick showing along with the rendered yes and no box, and the tick actually responding with the yes toggle, any idea why this is happening?
Need to add a function to change from 'yes' to 'no' programatically. UPDATE: I reviewed documentation and there is lack of information likes examples no change cheked values. Closing this Issue to create a pull request with some examples added.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.