-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Checkbox & Toggle button duplicating #391
Comments
May I see the html code before javascript edits it? |
Good advice. |
I've had the same issue with perfectly fine HTML. In my case it happened because init() (or checkbox() or togglebutton() ) was called multiple times. Each additional time resulted in another To fix it, I had to override one of material internal functions as follows: $.material.togglebutton = function(selector) {
// Add fake-checkbox to material checkboxes
$((selector) ? selector : this.options.togglebuttonElements)
.filter(":notmdproc")
.filter(function(){ //added this filter to skip checkboxes that were already initialized
return $(this).parent().find(".toggle").length === 0;
})
.data("mdproc", true)
.after("<span class=toggle></span>");
}; You might want to do the same for checkboxes. |
This is actually an issue when using with AngularJS and ArriveJS. Using @danbars snippet works for toggle buttons. Thanks !! $.material.checkbox = function(selector) {
// Add fake-checkbox to material checkboxes
$((selector) ? selector : this.options.checkboxElements)
.filter(":notmdproc")
.filter(function(){ //added this filter to skip checkboxes that were already initialized
return $(this).parent().find(".check").length === 0;
})
.data("mdproc", true)
.after("<span class=check></span>");
}; No more duplicate toggle button or check boxes:
|
I ran into this same issue and applied @danbars edit to my local distro for radio buttons. My issue was using Knockout with a collection... Please merge this in and make it available for the next release. Very helpful. :) |
I also encountered this with Knockout.js observable usage with the "if" binding. This caused it to fire the init method twice. (when loading the dom and on if condition becoming true in knockout). I worked around it by using the "visible" binding instead of the "if" binding. However,merging the above would be useful. |
@sthum : Can you please guide me the scenario in which checkbox are getting added dynamically? as the above code is overall avoiding the checkbox to initialise |
Good afternoon,
I'm currently having a problem with freshly cloned bootstrap-material-design.
My checkboxes and toggle buttons are appearing duplicated like here:
It doesn't matter which box I check - both are checking.
At toggle button we always have both states - turned on and off.
Any ideas what could cause that? Every other element works without any problems...
Have a nice weekend,
versedi
P.S. Posibble duplication of issue, but I'm not using NET:
https://github.com/FezVrasta/bootstrap-material-design/issues/147
The text was updated successfully, but these errors were encountered: