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'
  }); 
Rate this blog entry:
JQuery Validate Multiple Dynamic Inputs
JQuery Validate Single Input on Toggle

Comments

 
No comments yet

Latest Comments

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!!?
Johmny Invisible Mouse Cursor Ubuntu & Synergy
September 2, 2015
Glad I was ble to help!
Kristian Falk Invisible Mouse Cursor Ubuntu & Synergy
September 1, 2015
Thank you for this! Had the exact same problem. I almost went crazy.