Bootstrap Toggle Adding Dynamic Elements

If you are adding elements to your page dynamically you will may run into issues with Bootstrap Toggle.


I was adding toggles, each with uniquie ids.


Hopefully this will help;

  // destroy all toggles beginning with 'my-toggle'
  $("input[id^='my-toggle']").bootstrapToggle('destroy');     
  // re-initialise the toggles
  $("input[id^='my-toggle']").bootstrapToggle({
    on: 'No',
    off: 'Yes',
    onstyle: 'danger'
  }); 
JQuery Validate Single Input on Toggle
JQuery Validate Multiple Dynamic Inputs
 

Comments

No comments made yet. Be the first to submit a comment
Already Registered? Login Here
Guest
February 27, 2020

Captcha Image

Latest Comments

Guest - Susan Hermiston Virtual Hosts
October 7, 2015
Wow 747 just blew me away. Sorry not a tech person at all!! But I still love you!! Rock on!!?
Guest - Johmny Invisible Mouse Cursor Ubuntu & Synergy
September 2, 2015
Glad I was ble to help!
Guest - Kristian Falk Invisible Mouse Cursor Ubuntu & Synergy
September 1, 2015
Thank you for this! Had the exact same problem. I almost went crazy.