Some of you might face a situation where our function is executed more than once and that too automatically. As said, let say we have clicked a button one time, but it's calling function is called more than once. This type of problem majorly occurs in Accordians.
For such kind of situation you just need to modify your code a little bit and everything will run in a proper manner.
Just add "event" in the function() and check for (event.handled != true). For the first time this condition will be true because we have not defined event.handled anywhere, so it's undefined at first time.
At the end of your function add (event.handled = true), this will apply a value and next time the condition will become false. So your code will not be a hit on single click.
Example:
- $(document).on('click', '.btnSubmit', function (event) {
- if (event.handled != true) {
-
-
- ------------>>>>>>>>>>>
-
-
- Your Code
-
- ---------------<<<<<<<<<<<<<<<
- event.handled = true;
- }
- });