Input tags in ng-repeat stopping form submitting when enter key pressed

317
March 25, 2017, at 04:59 AM

I have a fairly simple form like this

<form name="{{vm.formName}}">
    <input name="emailAddress" type="text" ng-model="s4pDataForm.emailAddress" />
</form>

This works fine and the form submits when you focus the textbox and hit the enter key (I am binding a function call to the submit event using another directive not shown here instead of using ng-submit).

The problem comes when I try to dynamically create the input boxes inside an ng-repeat.

<form name="{{vm.formName}}">
    <input name="emailAddress" type="text" ng-model="s4pDataForm.emailAddress" />
    <div ng-repeat="control in vm.layout.controls">
        <input name="field-{{control.name}}" type="text" ng-model="vm.fields[control.name]" />
    </div>
</form>

The form renders perfectly. I can add dynamic validation, the model is wired up correctly etc. However the form only submits when I press the enter key if the first input is focused (the one outside the repeater). If you are focused inside any of the dynamically created input fields then it doesn't submit.

I've been banging my head against a brick wall for the last hour. My original dynamic form was huge but I've got it down to this minimal test case and it makes no sense. I can only assume that because the controls are dynamically added they are not considered part of the form by the browser so they can't submit the form?

READ ALSO
React-native PushNotificationIOS register and registrationError events never firing

React-native PushNotificationIOS register and registrationError events never firing

I'm trying to get the device token in a react-native app on iOS so I can receive push notificationsFrom what I understand, the only way to get the token is to listen to the register event, and the only way to fire the register event is to call PushNotificationIOS

609
looping javascript function on [x] number of elements

looping javascript function on [x] number of elements

I thought I wanted to expand all details tags so I followed zer00ne's answer here: Expanding all details tagsThat worked well but apparently I need to skip a few tags

307
Insert data from variable javascript

Insert data from variable javascript

I have a variable named score type int in javascriptI want to update a column from database

483
Can i use $angular timeout in a return statement?

Can i use $angular timeout in a return statement?

I am using Parse data, but the deal is, i want to return the variable ParseUserArray, but just after it passing by the success promisseI was wondering how can i do that

382