I'm having the following problem sirs.
I have the following function
function sortTable() {
arr = JSON.parse(localStorage.context_data);
$('#tableLemos th').click(function () {
console.log("funcao carregada...")
var id = $(this).attr('id');
var asc = (!$(this).attr('asc')); // switch the order, true if not set
// set asc="asc" when sorted in ascending order
$('#tableLemos th').each(function () {
$(this).removeAttr('asc');
});
if (asc)
$(this).attr('asc', 'asc');
sortResults(id, asc);
});
}
and also this
function request(url) {
dados = [];
$.ajax({
type: "GET",
contentType: "application/json; charset=utf-8",
//url: "http://localhost:8080/WEB/web/configFields/" + field,
url: url ? url : "http://localhost:8080/WEB/web/usuarios/find/",
dataType: "json",
success: function (data) {
dados = data;
localStorage.setItem("context_data", JSON.stringify(data));
transform_table(JSON.stringify(data));
}});
sortTable();
}
As a rule, every time I call the request()
function the sortTable()
function should be executed, but it does not happen, and detail if I open the Chrome console and run the sortTable()
/ p>
More in detail:
onClick = request()
event, to call the request()
function; click
event that is inside the function, which does not happen without opening the Chrome console and calling the function there. What do you guys think?