minhur / bootstrap-toggle

Bootstrap Toggle is a highly flexible Bootstrap plugin that converts checkboxes into toggles
http://www.bootstraptoggle.com
MIT License
1.48k stars 440 forks source link

Add bootstrap toggle checkbox through javascript #15

Open KrishnaMurariVijay opened 9 years ago

KrishnaMurariVijay commented 9 years ago

When i use on jsp page.It shows button the way it should be shown.But when i add it through javascript he it shows only a checkbox not the toggle button.What is the issue?

minhur commented 9 years ago

could you show me a code snippet?

BasDeBas commented 9 years ago

I seem to have the same problem. As a response to user input I create dynamic elements as html strings which I add with getelementbyId. e.g.: 'strBeoord += '\n';'

When i put "" directly on my html page it works fine!

briansol commented 9 years ago

Sounds like you need to use a delegated event for the init. Anything added to the DOM after DOMready will need to be attached in this manner.

https://learn.jquery.com/events/event-delegation/

codeconqueror commented 8 years ago

Just a workaround, but after adding the checkbox, use the following (you'll need to adjust the selector to select just the new checkbox you added though):

$('input:checkbox').bootstrapToggle();