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
October 31, 2020

Captcha Image

By accepting you will be accessing a service provided by a third-party external to https://www.johnnyshongo.com/