$.extend($.jgrid.ajaxOptions, { async: true });
$.extend($.jgrid.defaults, {
mtype: "POST",
altRows: true,
datatype: "json",
loadonce: true,
height: "auto",
width: 1100,
rowNum: 10,
rowList: [10, 20, 30, 40, 50],
viewrecords: true,
pager: "#paginacao",
sortorder: "asc",
shrinkToFit: false,
headertitles: true,
loadui: "disable",
rownumbers: true,
emptyrecords: "<strong>Não houve resultado para o seu filtro.<strong>",
autoencode: true,
caption: "Resultados encontrados",
deselectAfterSort: true,
gridview: true,
idPrefix: "id",
rowTotal: 4000,
sortable: true,
toppager: true,
loadError: function(xhr, status, error) {
$.blockUI({
message: '<p style=\"font-weight: bolder; color: white;\">Erro ao tentar gerar relatório, por favor, tente novamente.<br /><br /><a onclick=\"$.unblockUI();\">Fechar</a></p>',
timeout: 5000,
onOverlayClick: $.unblockUI
});
},
jsonReader: {
root: "rows",
page: "page",
total: "total",
records: "records",
repeatitems: true,
id: 0,
cell: ""
}
});
But doing so the plugin does not work at all. But when I play the call to blockUI inside a window.setTimeout as below it works perfectly:
loadError: function(xhr, status, error) {
window.setTimeout("$.blockUI({ message: '<p style=\"font-weight: bolder; color: white;\">Erro ao tentar gerar relatório, por favor, tente novamente.<br /><br /><a onclick=\"$.unblockUI();\">Fechar</a></p>', timeout: 5000, onOverlayClick: $.unblockUI});", 10);
}
Does anyone know how to make the call to blockUI run without having to use it inside a window.setTimeout
?
In time, all native JavaScript functions like parseInt
, parseFloat
, alert
, console.log
work, which leads me to believe that the problem is how blockUI
handles Ajax, problem that uses it asynchronously as it requires and does not even work without window.setTimeout
.
EDIT: According to the utluiz response, there may be some conflict with my default settings of how I handle AJAX requests, follows the configuration:
$.ajaxSetup({
type: "POST",
dataType : "json",
cache : false,
error : function(xhr, statusRequestAjax, error) { $("#msgErros").html(error); },
beforeSend: function() { $.blockUI(); },
complete : function() { $.unblockUI(); }
});