1.1.21 add function for checking the status of the switch finish_subscribe_msg

This commit is contained in:
2024-06-28 15:17:39 +03:00
parent e2b7b0d356
commit afb0ea0bed
2 changed files with 31 additions and 1 deletions

View File

@@ -804,6 +804,30 @@ function send_subscribe (el, id, for_movers, subscribe){
}
}
function updSwitchState(el){
let stateToSend = el.checked
$.ajax({
headers: { "X-CSRFToken": $('input[name=csrfmiddlewaretoken]').val() },
url: '/subscribes/receive_finish_subscribe_msg/',
type: "POST",
// async: true,
cache: false,
processData: false,
contentType: false,
// enctype: 'json',
data: { receive_finish_subscribe_msg: stateToSend },
success: function(response){
alert(response)
},
error: function (data, exception){
console.error('Произошла ошибка при выполнении AJAX запроса:', exception);
console.log(data.responseText);
}
});
}
var last_open_curtain = null
function open_curtain_w_btn_profile () {

View File

@@ -32,7 +32,13 @@
<label for="id_email_toggle">{% translate "Получать уведомление на почту о завершении подписки" %}</label>
</div>
<div class="toggle_switch_cont">
<input class="input_toggle_switch" id="id_email_toggle" name="email_toggle" type="checkbox">
<input class="input_toggle_switch"
onchange="updSwitchState(this)"
id="id_email_toggle"
name="email_toggle"
type="checkbox"
{% if subscribe_for_user.receive_finish_subscribe_msg == True %}checked{% endif %}
>
<div class="input_toggle_switch_display"></div>
<div class="toggler_input_switch"></div>
</div>