1
$(document).ready(function(){
    //other stuff
    $(".active_item").click(function() {
        $("body").css("cursor", "progress"); //tried wait instead of progress as well
        window.setTimeout(someLength,4000);//just to make sure we do switch back at some point
        $('#list tbody tr').each(function(i) {
            $(this).removeClass('invisible_row');
        });
        $("#list tbody tr").show();
        $('.catnav').each(function(i) {
            $(this).removeClass('current_category');
        });
        $("body").css("cursor", "default");
    });
});

I've checked other questions like Changing cursor to waiting in javascript/jquery

but in my code it doesn't work (the cursor does not change to "progress", or "wait" if I choose that one).

Community
  • 1
  • 1
transient_loop
  • 5,984
  • 15
  • 58
  • 117
  • 2
    You're setting the cursor and then immediately setting it back. There's no net effect. – Pointy Oct 16 '13 at 17:18
  • to put it another way, `$("body").css("cursor", "progress").css("cursor", "default")` would be identical to what you're currently doing with the cursor. – Kevin B Oct 16 '13 at 17:21
  • Oh I see, you mean because of the async functions? – transient_loop Oct 16 '13 at 17:21
  • the only async-ish function you have is the setTimeout, is that what you're referring to? – Kevin B Oct 16 '13 at 17:24
  • hmm. OK. So I set the cursor to progress. Then I call each, show, and each. I would like to set the cursor back when these three functions are done...But I am setting the cursor back before those three have finished. Is this the issue? – transient_loop Oct 16 '13 at 17:26
  • Obviously there's something very fundamental I haven't understood in javascript... – transient_loop Oct 16 '13 at 17:34

1 Answers1

0

You could try and use the show() function as a timer, so that your cursor will stay in 'progress' at least a second.

$("#list tbody tr").show(1000 // Enter the time you want here , function(){$("body").css("cursor", "default");});

That way your cursor will reverse back to default after the function show() completes, which takes 1 second (in my example).

You can check .show() documentation for more information.

Mat
  • 38
  • 1
  • 7