Skip to content
This repository has been archived by the owner on Jan 9, 2023. It is now read-only.

Conflict between ng-disabled and promise button #45

Closed
landrytaffin opened this issue Dec 13, 2017 · 1 comment
Closed

Conflict between ng-disabled and promise button #45

landrytaffin opened this issue Dec 13, 2017 · 1 comment

Comments

@landrytaffin
Copy link

Hello,

During the promise resolution, if ng-disabled value changes to false, then once the promise is resolved, the disabled attribute is always removed (not taking into account the state of ng-disabled).

We made a small fix on our local version:

  1. We added ngDisabled in the directive's scope
  2. We modified handleLoadingFinished to take into account ngDisabled value

So here it is:

function handleLoadingFinished(btnEl) {
    if ((!cfg.minDuration || minDurationTimeoutDone) && promiseDone) {
        if (cfg.btnLoadingClass) {
            btnEl.removeClass(cfg.btnLoadingClass);
        }
        if (cfg.disableBtn && !scope.ngDisabled) {
            btnEl.removeAttr('disabled');
        }
    }
}

AND

return {
    restrict: 'EA',
    priority: angularPromiseButtons.config.priority,
    scope: {
        promiseBtn: '=',
        promiseBtnOptions: '=?',
        ngDisabled: '='
    },
    ...

Could you include this as a feature in you next version of the directive ?
Thank you.

@johannesjo
Copy link
Owner

Hey! Thanks for the suggestion. I implemented your fix.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants