1

I have a empty page where i dinamically add the element, i'm tryng to use materialize and i have a graphic problem...

I have follow the different tutorial on "http://materializecss.com/" to add the element with the correct method, but i have a problem with checkbox...

If i add the checkbox directly on the HTML page i have some graphic effect on checking and unchecking checkbox, but i must add it with javascript/jquery (dinamically) and i lost the graphic error.

On the website there is some initialization function to solve similar problem, but there isn't a initialization function for checkbox...

Someone say how to manually initialize checkbox with Materialize? ty!

edit: enter image description here

i have id and for on my checkbox...

sorry gor difficult code but it it's everithing dinamically added...

Il_Sapo
  • 141
  • 1
  • 9

2 Answers2

1

You have to have <span> right after your checkbox. Thing is that all magic about creating nice checkbox happens inside of span rather than input itself.

So here is minimal structure of HTML to get fancy checkbox in Materialize

<input type="checkbox" />
<span></span>
0

When you add them dynamically, do you also add the for attribute in the label for the checkbox? Per Materialize's documentation for Checkboxes:

The for attribute is necessary to bind our custom checkbox with the input. Add the input's id as the value of the for attribute of the label.

An ID should be unique within a page.

chrki
  • 6,143
  • 6
  • 35
  • 55
adriennetacke
  • 1,726
  • 1
  • 14
  • 21
  • @ll_Sapo Did you searched for any other element in `DOM` with same `id`? Id should be unique to one particular element. – Dipak Nov 20 '16 at 11:43