-1

I am attempting to add in a javascript "please wait" spinner, so my end user has an idea that something is happening while a long loading event occurs. We are using ASP.NET. There is a problem, however, in that we are using a lot of Peter Blum's validators on the page. As it stands right now, I am using a click event on the continue button like so:

var btnContinue = $("input[name*='btnContinue']");
        $(btnContinue).click(function() 
        {
            # show the spinner
        }

This causes a problem if the validation fails, because the validation errors will pop up but the spinner will not go away. I don't really see a single OnAllValidation() event or something that I can hook into easily to get the behavior I'm really wanting (start spinning after validation when we know everything's okay). This order of events is problematic because some of the validation happens after the post back, which means I lose the ability to check these conditions in Javascript. At least, without an event I could hook into.

Anyone have any ideas?

tmesser
  • 7,558
  • 2
  • 26
  • 38
  • @eric.itzhak Forgive me, but I'm not really understanding how that would solve the problem since the Continue.Click event happens before any validation at all happens. Could you go in a bit more? – tmesser May 21 '12 at 13:48
  • Oh didn't get that in the question, then you can show the spinner after validation ends instead in the OnClick event. – eric.itzhak May 21 '12 at 13:52
  • @eric.itzhak Yeah, after validation ends is where I'm trying to target, but I'm having trouble getting it to do that. We are using commercial validators so things are somewhat 'black box' and wired in to the overall flow of our ASP.NET pages. – tmesser May 21 '12 at 15:07

2 Answers2

1

I found what I was looking for in Mr. Blum's Validation Users Guide. Specifically:

function DES_ValidateGroup(pGroup)

This will run client-side validation on the specified validation group on the current page, using the DES Client-side framework. Having an in like this allowed me to simply put this into an IF statement.

In my case I need the whole page to validate, so I simply left pGroup blank, making the invocation look like this:

DES_ValidateGroup('')

The user's guide enumerates that this is totally kosher.

tmesser
  • 7,558
  • 2
  • 26
  • 38
0

You can :

  • Make the spinner appear inside the validation functions
  • Call the validation functions inside the onclick event

This will probably solve your problem.

If that dosen't satisfiy you, check out This answer, which explains a method to do this using jQuery's when() method, not sure will be relavent but check it out.

Community
  • 1
  • 1
eric.itzhak
  • 15,752
  • 26
  • 89
  • 142
  • I probably should've been more explicit about this, but the reason I specified Peter Blum's validators is because all of the validation takes place after the post-back, and when I'm going to go rolling around in Javascript to display the spinner I don't have any visibility to that. Unless I'm mistaken about how I can hook in to these controls? I'll start experimenting with your solution, I certainly don't have anything to lose at this point! – tmesser May 21 '12 at 14:14