Skip to content

Instantly share code, notes, and snippets.

@AndreFSilveira
Created November 7, 2018 19:27
Show Gist options
  • Save AndreFSilveira/9d2425405e9520fb079eea5e318007f4 to your computer and use it in GitHub Desktop.
Save AndreFSilveira/9d2425405e9520fb079eea5e318007f4 to your computer and use it in GitHub Desktop.
Remove duplicate toggle and checkbox with materialize. add this code before $.material.init();
...
$.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>");
};
$.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>");
};
...
$.material.init();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment