jquery - Bootstrap modal "shown.bs.modal" does not alter my checkbox inside the modal -


i have check boxes need loaded when page loads. dictionary provided djangotemplate , check check boxes.

i tried using "shown.bs.modal" executes codes, later found out check boxes set default un-checked.

i found out using setinterval() set check boxes working want. seems after modal loads takes 1 - 2 seconds before check boxes checked. so, happen after "shown.bs.modal" reset check boxes un-checked.

my solution far use settimeout() after "shown.bs.modal" check check boxes. still wondering cause.

/* used detect if modal page button triggered or not. these codes not set check boxes checked. */ $("#sample").on("shown.bs.modal", function(event) {   (var = 0; < index_checkbox.length; ++) {     console.log("something happened here");     $("#checkbox-" + index_checkbox).prop("checked", true);     console.log("the value of `prop('checked')` changed");     console.log("but later goes `false`");   } }).modal("show");  // these codes checked check boxes after 1 - 2 seconds. window.setinterval(function () {   (var = 0; < index_checkbox.length; ++) {     $("#checkbox-" + index_checkbox).prop("checked", true);   } }, 1000);  // checkbox generated djangotemplate. <input id="checkbox-{{ teacher.id }}" type="checkbox" name="teacher"     value="{{ teacher.id }}"     ng-model="teacher_checkbox[{{ forloop.counter0 }}]" /> 

edit: actually, setting setinterval() 100 millisecond works. if possible want not use setinterval().

edit: interval of 0 works. confused....

you have wrap bootstrap events, 'shown.bs.whatever' in either a

$(document).ready( function()  }); 

or

$(function(){  }); 

Comments

Popular posts from this blog

neo4j - finding mutual friends in a cypher statement starting with three or more persons -

php - How to remove letter in front of the word laravel -

minify - Minimizing css files -