4

作成されたオブジェクトのフィールドの 1 つがundefined. オブジェクトは次のとおりです。

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;
};

オブジェクトのリストを保存していますが、フィールドを除いて、オブジェクトの各フィールドは適切に保存されていstatusます。statusフィールドを単独で呼び出すと正しい値がnote.status返されますが、アクセスしようとするとundefined.

オブジェクトのリストを作成するコードは次のとおりです。

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;
            }
        });
    });     
};

他のすべてのnote.呼び出しでは、変数は正しいです。status返すだけですundefined。オブジェクトは正しい値を格納していましたが、しばらくすると、何も変更せずに値が になりましundefinedた。何か案は?前もって感謝します!

4

1 に答える 1