I have a problem when one of the fields in the created object is undefined . Here's the object:
var Collateral = Collateral || {}; Collateral.NoteModel = function(config) { "use strict"; this.loanId = config.loanId; this.docId = config.docId; this.borrowerName = config.borrowerName; this.funder = config.funder; this.docsDrawn = config.docsDrawn; this.firstPayment = config.firstPayment; this.loanAmount = config.loanAmount; this.interestRate = config.interestRate; this.dateDocsIn = config.dateDocsIn; this.status = config.status; this.eventDate = config.eventDate; this.submittedBy = config.submittedBy; };
I save a list of objects, and each field of the object is stored correctly, except for the status field. When I call the status field on its own, it returns the correct value, but when I try to access note.status , it returns undefined .
Here is the code to create a list of objects:
var renderNotesList = function(url, data, elementId, liFunc) { $.getJSON(url, data, function(response) { var notesList = []; renderNotesList.divider; $(elementId).empty(); $(response).each(function() { var entry = $(this)[0]; var note = new Collateral.NoteModel({ //initialize note object loanId: entry["Loan_ID"], docId: entry["Doc_ID"], borrowerName: entry["Borrower_Name"], funder: entry["Funder"], docsDrawn: entry["Docs_Drawn"], firstPayment: entry["First_Payment"], loanAmount: entry["Loan_Amount"], interestRate: entry["Interest_Rate"], dateDocsIn: entry["Date_Docs_In"], status: entry["Event_Type"], eventDate: entry["Event_Date"], submittedBy: entry["Submitted_By"] }); console.log(entry["Event_Type"]); // here the value is correct console.log(note.status); // here the value is "undefined" var li = liFunc(note, renderNotesList.divider); li.appendTo($(elementId)); try { $(elementId).listview('refresh'); } catch(e) { return; } }); }); };
For all other note. calls note. the variables are correct. Only status returns undefined . Objects kept the correct values, but after a while, without changing anything, the values โโbecame undefined . Any ideas? Thanks in advance!