angular-autodisable
angular-autodisable copied to clipboard
ngAutodisable directive for angular. Automatic disable for buttons rocks!
Allows multiple buttons with `type="submit"`. Fixes `$ is not defined` error with webpack etc. by using `angular.element` and `$document.find`.
One might want to disable / enable form inputs depending on some state. Currently, ng-autodisable and ng-disabled don't work well together, and we could have the situation where ng-autodisable has...
cause ngTouch module's ngClick directive using touch event to trigger click event. and disabled element can trigger touch event. so this won't work. I can send a PR to fix...
Here is my jade template ``` form(name='signInForm' ng-submit="signIn()" ng-autodisable) input(type="email" ng-model="email" placeholder='Email' ng-required='true') input(type="password" ng-model="password" placeholder='Password' ng-required='true') button(type="submit" ng-disabled="signInForm.$invalid") Sign In ```
Added support for using require('angular-autodisable'). Added support for npm run build. Added dev dependencies. Inspired by the pull request from @lili21
therefore, this snippet never finds any buttons to disable ``` handler = handlerInstance(element.find('button[type=submit]'), SUBMIT_EVENT, getLoadingClass(attrs), getCallbacks(attrs[SUBMIT_ATTR])); ``` maybe you could use something like `element[0].querySelectorAll('button[type=submit]')` instead?
The prefix ng-\* in directive might conflict with future native directives.
I'm trying to use this directive on a form with a `button[type="submit"]`. The problem is... The child button is generated in a directive itself. (`Submit