GithubHelp home page GithubHelp logo

markpieszak / angular1-ngform-ngsubmit-fixes Goto Github PK

View Code? Open in Web Editor NEW
13.0 13.0 5.0 32 KB

Fix Angular1.* ng-form & ng-submit issues. AngularJS by default doesn't handle <ng-form> the way a typical <form> is handled, Enter keypress doesn't submit, ng-submit also doesn't work with it. Fix all of those issues with this directive override.

License: Other

HTML 61.53% JavaScript 38.47%

angular1-ngform-ngsubmit-fixes's Introduction

angular1-ngform-ngsubmit-fixes's People

Contributors

appletouch avatar christheyounger avatar christiangalla avatar echochristopher avatar esson avatar markpieszak avatar moshfeu avatar vantanev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

angular1-ngform-ngsubmit-fixes's Issues

Form submission handling is not correct in all cases

Hi @MarkPieszak I found this repo while investigating the issue of ngForm submission for AngularJS core, and if this can be handled reliably by a third party directive. It's cool to see that this works. I've found a few issues though, and I know that this is a low activity repo, but maybe we can work on them together.

  • Submission rules for Enter / click doesn'T follow HTML spec. Since we want to follow regular form element rules, the rules need to be a bit more refined:
    • when there is more than one input element in the form, and no submit button, Enter should not submit the form
    • when there are multiple submit buttons, all of them should submit the form on click (atm only the first one that is found gets the click handler)
    • buttons without a type must also be considered submit buttons
  • Implementation issues:
    • finding the submit button doesn't account for dynamically generated buttons
    • calling the ngSubmit function should trigger an apply like it does in the regular form
    • "submit event" should call formController.$setSubmitted() instead of setting the classes and props manually
    • interop with regular forms is unclear. Imo, if you have only a single form, then you should use the regular <form> attribute. If you have a parent <form> or <ng-form>, then it shouldn't prevent the events from bubbling up, imo. It should only do that if the form if the form is not attached to the parent (a state that doesn't currently exist in AngularJS).

Could a license be added?

Could we add a license, e.g., MIT? I believe the current "default" is copyrighted, all rights reserved.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.