mirror of
https://github.com/slawkens/myaac.git
synced 2025-04-26 17:29:21 +02:00
feat: Settings: enable Save button only if changes has been made
This commit is contained in:
parent
4fda4f643b
commit
28fef952f8
@ -80,7 +80,26 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#settings').submit(function(e) {
|
const noChangesText = "No changes has been made";
|
||||||
|
|
||||||
|
$('form')
|
||||||
|
.each(function(){
|
||||||
|
$(this).data('serialized', $(this).serialize())
|
||||||
|
})
|
||||||
|
.on('change input', function(){
|
||||||
|
const disable = $(this).serialize() === $(this).data('serialized');
|
||||||
|
$(this)
|
||||||
|
.find('input:submit, button:submit')
|
||||||
|
.prop('disabled', disable)
|
||||||
|
.prop('title', disable ? noChangesText : '')
|
||||||
|
;
|
||||||
|
})
|
||||||
|
.find('input:submit, button:submit')
|
||||||
|
.prop('disabled', true)
|
||||||
|
.prop('title', noChangesText)
|
||||||
|
;
|
||||||
|
|
||||||
|
$('#settings').on('submit', function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
@ -94,6 +113,13 @@
|
|||||||
duration: 3000,
|
duration: 3000,
|
||||||
escapeMarkup: false,
|
escapeMarkup: false,
|
||||||
}).showToast();
|
}).showToast();
|
||||||
|
|
||||||
|
let $settings = $('#settings');
|
||||||
|
$settings.data('serialized', $settings.serialize());
|
||||||
|
$settings
|
||||||
|
.find('input:submit, button:submit')
|
||||||
|
.prop('disabled', true)
|
||||||
|
.prop('title', noChangesText);
|
||||||
},
|
},
|
||||||
error : function(response) {
|
error : function(response) {
|
||||||
Toastify({
|
Toastify({
|
||||||
@ -109,6 +135,7 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
{% for key, value in settings %}
|
{% for key, value in settings %}
|
||||||
{% if value.type == 'password' %}
|
{% if value.type == 'password' %}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user