javascript - jQuery Bootgrid how to check if bootgrid is still loading -
i have implemented jquery bootgrid. want manage showing , hiding loader i've implemented.
the loader shown , hidden $("#ajaxloader").show();
, $("#ajaxloader").hide();` respectively.
and have bootgrid initialization implemented follows:
var grid = $('#grid').on("load.rs.jquery.bootgrid", function () { $("#ajaxloader").show(); }).bootgrid({ ajax: true, ajaxsettings: { method: "get", contenttype: "application/json; charset=utf-8", datatype: "json", cache: false }, searchsettings: { delay: 500, }, url: myurl, rowcount: [5, 10, 50, 75, 100, 200, -1] }).on("loaded.rs.jquery.bootgrid", function (e) { $("#ajaxloader").hide(); });
now works fine want optimize in 2 ways:
bootgrid's search functionality seems have it's own loader there way in order not show ajax loader if search occurring?
my loader pops , hides on short queries. there way can delay happening?
solving option 2 solve option 1 on it's own anyway here i've tried regarding option 2.
i tried settimeout(function () { $("#ajaxloader").show(); }, 1000);
, never gets hidden again. counter solved using settimeout(function () { $("#ajaxloader").hide(); }, 1000)
flashes show , hide unnecessarily.
so ideally need check if bootgrid still loading before apply function.
how can solve loading problem?
edit:
i've tried setting loading
variable on load
method say:
loading = true; settimeout(function () { if (loading) { $("#ajaxloader").show(); }}, 1000);
and following on loaded
event:
settimeout(function () { $("#ajaxloader").hide(); }, loaderdelay);
that still gave me same flashing error.
i solved using cleartimeout()
function this:
var showloader; var grid = $('#grid').on("load.rs.jquery.bootgrid", function () { showloader = settimeout(function () { $("#ajaxloader").show(); }, 1000); }).bootgrid({ ajax: true, ajaxsettings: { method: "get", contenttype: "application/json; charset=utf-8", datatype: "json", cache: false }, searchsettings: { cleartimeout(showloader); delay: 500, }, url: myurl, rowcount: [5, 10, 50, 75, 100, 200, -1] }).on("loaded.rs.jquery.bootgrid", function (e) { $("#ajaxloader").hide(); });
Comments
Post a Comment