#Toggle switch
5 messages · Page 1 of 1 (latest)
I also think that one approach would be to register an event in JS.
no i didn't
What HAVE you tried?
<script>
$(document).ready(function () {
$('#myToggle').on('change', function () {
const isChecked = $(this).is(':checked');
const status = isChecked ? 'on' : 'off';
const botid = $('tr').attr('data-pk');
$.ajax({
url: `{% url "status-update" ${botid} %}`, // Sending checkbox state as a GET parameter
type: 'GET',
success: function (response) {
console.log('Success:', response.message);
},
error: function (xhr, status, error) {
console.error('Error:', error);
}
});
});
});```