I am using formsets so add button adds the form but I want to remove them after the delete checkbox has been checked (where i need help), I dont understand much javascript.
Here might be the answer but it does not work for me: Can't understand why this error(Uncaught TypeError: $(...).is(...).each is not a function) got on? when I try this code:
$("input[class='remove-form']").click(function(){
var n = $( "input[type='checkbox']:checked" ).length;
console.log('n here',n)
$("input[type='checkbox']:checked").each(function(){
// $(this).parents('.form-row').remove();
console.log('removed');
})
})
only the first checkbox works(which wasn't added dynamically)(or in log case shows the number of boxes checked). The dynamically created checkboxes don't just show any response.
The Form which will be appended:
<div id="items-form-container" style="display: none;">
....
<div class="col-2">
<label>Delete</label>
</div>
<div class="col-4">
<div class="input-group">
<input type="checkbox" name="quizz_question-__prefix__-DELETE" class="remove-form"
id="id_quizz_question-__prefix__-DELETE">
</div>
</div>
In short the dynamically added checkboxes doesn't work in my ajax function.Please HElp.
Aucun commentaire:
Enregistrer un commentaire