-1

All:

There is a common operation in my Angular project is:

Click a button, init AJAX call, download data. But there is one thing related to user action which is multiple clicks in very short time( probably for fun purpose? ), those requests carry same calls, and what I want to do is how to prevent those dup calls and only allow one fired?

I am currently using Angular $http.

Thanks

Kuan
  • 11,149
  • 23
  • 93
  • 201
  • Can you just disable this button after first click until AJAX call is in completed? – serhiyb Jan 25 '16 at 22:13
  • @serhiyb Thanks, that is great way from UI perspective( I will use it if can not figure it out), I wonder if there is any simple code which can solve this from logic perspective(because I also need to use that request handler in some places which may not a short time but as long as until the data returns)? – Kuan Jan 25 '16 at 22:15

1 Answers1

1

In my apps I'm using Ladda buttons (angular directive) https://github.com/remotty/angular-ladda to disable button and show loading indicator.

Here is an example of how it looks: http://remotty.github.io/angular-ladda/

serhiyb
  • 4,753
  • 2
  • 15
  • 24
  • thanks, this is very cool UI – Kuan Jan 25 '16 at 22:20
  • Ladda button only disable buttons, how about affected input fields or select elements? I usually disable an area by set some vairable and use it on all affected elements. – Justin Jan 25 '16 at 22:39