angular-payments icon indicating copy to clipboard operation
angular-payments copied to clipboard

Disabled property on button

Open apitts opened this issue 11 years ago • 6 comments

Wondering what the rationale is for setting button.prop('disabled', true) and then false. Would it not be easier to let the user handle this via ng-disabled? Use case is that I use angular-payments to generate a token and then use stripe.js to create a customer. While waiting for the response on creating the customer the button is enabled but disabled for the initial token request.

apitts avatar May 26 '14 08:05 apitts

I have this problem also. I think it would be better to let the user manage the 'disabled' state of the button - what if there are other buttons on the form?. If you really want this functionality, maybe it could be controlled by some sort of option on the relevant 'button' element.

twilkinson avatar Jan 04 '15 20:01 twilkinson

+1

so, what do you guys use to simulate this?

ikhattab avatar Apr 14 '15 10:04 ikhattab

+1

mck- avatar May 04 '15 20:05 mck-

Hey guys,

Try https://github.com/bendrucker/angular-stripe (you call it and it returns a promise instead of it calling your callback via the scope) and pair it with https://github.com/bendrucker/angular-form-state for managing submission state and syncing your submit button.

bendrucker avatar May 04 '15 20:05 bendrucker

+1

vdieulesaint avatar May 15 '15 13:05 vdieulesaint

So I don't know why this didn't occur to me before, but you can avoid the problem by not using a 'button' html element. Use:

<input type="submit" data-ng-disabled="processing" value="Submit" />

in the form, and set a $scope variable named 'processing' to true when the form is submitted, and to false when you get the response from your server.

The 'laurihy/angular-payments' library messes with a 'button' element, but not with an 'input' element as above.

twilkinson avatar May 16 '15 00:05 twilkinson