user28639
user28639

Reputation: 1

AngularJS button blur button after the click of the button

I am using AngularJS in a Salesforce implementation. There is a button which, when clicked, does a few automations in Salesforce - all good there. But the automation takes about 3-5 seconds to finish, thus prompting users to click the button more than once.

My requirement is, after the click of the button, the user should not be able to click the same button again. It should blur the button after the click of the button.

My code:

<div ng-show="ForRegistration">
    <input type="button" ng-click="saveLead( true );" ng-dbclick="" ng-disabled="myForm.$pristine || myForm.$dirty && myForm.$invalid" value="Continue" class="btn btn-default" role="button"/>
</div>

Upvotes: 0

Views: 994

Answers (1)

Shakir Ahamed
Shakir Ahamed

Reputation: 1308

Just try this

<div ng-show="ForRegistration">
    <input type="button" ng-click="saveLead( true );" ng-dbclick="" ng-disabled="isDisabled" value="Continue" class="btn btn-default" role="button"/>
</div>

you can keep $scope variable with bool value as false in your controller and update that variable in your saveLead method as true then after the first click button will be disabled

YourApp.controller('yourController',function ($scope) 
{
    $scope.isDisabled = false;
    $scope.saveLead = function ()
    {
        //here your code 
        $scope.isDisabled = true;
    };
});

Upvotes: 0

Related Questions