Skip to content

Init Parameter#8

Open
ja-k-e wants to merge 1 commit intogtramontina:masterfrom
ja-k-e:master
Open

Init Parameter#8
ja-k-e wants to merge 1 commit intogtramontina:masterfrom
ja-k-e:master

Conversation

@ja-k-e
Copy link
Copy Markdown

@ja-k-e ja-k-e commented Feb 20, 2015

Added an Init method to be called prior to Stripe Response on form submit. Disabling the button wasn't enough in my use case.

Added an Init method to be called prior to Stripe Response on form submit. Disabling the button wasn't enough in my use case.
@ja-k-e
Copy link
Copy Markdown
Author

ja-k-e commented Feb 20, 2015

You authored this thing awhile ago, but I figured I'd propose this change anyways in case you were interested. It ended up being really handy for me.

@gtramontina
Copy link
Copy Markdown
Owner

Sorry for taking too long to reply. There's really no excuse for that. 😁
Would you mind providing some usage examples? I just wanted to see what are the use-cases.

Thanks for contributing! 🍻

@ja-k-e
Copy link
Copy Markdown
Author

ja-k-e commented Aug 21, 2015

No problem on the response time.

It's been awhile since I used it, but the use case was needing a hook to apply a "requesting" state while submitting the Stripe form. This would come in handy for things like modifying a submit button's text while the form is submitting, then changing it back in the response method. Simplified:

<form stripe-form="stripeResponse" stripe-init="stripeInit">
  ...
  <button type="submit" ng-disabled="form.requesting">
    <span ng-if="!form.requesting">Make Payment</span>
    <span ng-if="form.requesting">Making Payment...</span>
  </button>
</form>
$scope.stripeInit = function() {
  $scope.form.requesting = true;
}

$scope.stripeResponse = function(status, response) {
  $scope.form.requesting = false;
}

Essentially, it could be used as a hook to toggle any desired behavior during form submit whether it's a loading spinner, making form inputs read-only, fieldsets disabled, or any sort of notification. Upside is that it doesn't assume anything and leaves submitting state up to whoever is using it.

Revisiting this, I'm not sure init is the best name for it, but that could easily be changed.

@ja-k-e
Copy link
Copy Markdown
Author

ja-k-e commented Aug 21, 2015

seems like an extension of #4 and potential solution for #10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants