-2
I have this function, where it checks the data, to exit the page, what happens that some data get like disabled according to the data reported, and I cannot verify the data.
$(function () {
var init_form = $('#Novo').serialize();
$(':submit').click(function () { window.onbeforeunload = null; });
window.onbeforeunload = function () {
var check_form = $('#Novo').serialize();
console.log(init_form);
console.log(check_form);
if (check_form === init_form) return null;
return 'Os dados do formulário não foram salvos, deseja permanecer nesta página?';
};
});
I tried to add this line in the method $("#Novo :input").prop('disabled', false); but it didn’t work either.
$(function () {
var init_form = $('#Novo').serialize();
$(':submit').click(function () { window.onbeforeunload = null; });
$("#Novo :input").prop('disabled', false);
window.onbeforeunload = function () {
var check_form = $('#Novo').serialize();
console.log(init_form);
console.log(check_form);
if (check_form === init_form) return null;
return 'Os dados do formulário não foram salvos, deseja permanecer nesta página?';
};
});
How can I make sure that all data is checked, regardless of whether the property disabled or readonly be as true.
But if you disable the inputs disabled and the user cancels the beforeunload, these inputs will be active. It wouldn’t be weird?
– Sam
Tried to put the
$("#Novo :input").prop('disabled', false);within the functiononbeforeunload?– Pedro Henrique
Is there any way to "circumvent" this, I put it as
readonlybut even so, some still does not appear in the comparison.– Mariana