0

Here is the javascript. This works perfectly and returns the array of objects, if the html inputs are hardcoded. However for some reason if these inputs are appended it does not work, and for that object all values are undefined.

        var companyOwners = $('.company_owners_details').map(function() {
            return {
                owner_first_name: $(this).find('[name="owner_first_name"]').val(), 
            };
        }).get();
user10001850
  • 13
  • 1
  • 4
  • Does that code get run after new elements are appended to the DOM? – Pointy Jun 27 '18 at 19:13
  • @Pointy No it runs after form validation when you click submit, after which of course these values are existant... if I run a console.log of the .val() of this appended input it returns the correct value – user10001850 Jun 27 '18 at 19:14
  • 1
    I am not sure that's the best duplicate. The posted code, however, is not sufficient to tell for sure. What's really needed is more context: how are the elements added, exactly, and where is the posted code run in relation to interaction with the page. – Pointy Jun 27 '18 at 19:16
  • 1
    @pointy feel free to reopen ... I'm not sure either (was a 51 : 49 decision) – Jonas Wilms Jun 27 '18 at 19:17
  • @Pointy the elements are added to a div using .append()... the posted code is below the html – user10001850 Jun 27 '18 at 19:18
  • @user10001850 the problem is you did not post enough for anybody to know for sure what the actual bug is. Your posted code is fine, so if there's something wrong that code is not the problem. – Pointy Jun 27 '18 at 19:20

0 Answers0