我有这个代码片段,它在其他地方工作得很好,但是当我将它移动到不同的部分时会给我一个循环引用错误。我什至在任何地方都找不到关于什么是循环引用的好参考。
// Create a new array to hold each of the Properties from the custom search pane
// This array will eventually be converted to JSON and become a List<Property>
propertyTables = [];
// Create new Object to hold a row - we have to construct these
// Property objects manually for each row
propertyRow = {};
// This needs to be rewritten to include all of hidden input elements from the custom object that is clicked
// For each of the data elements the properties table, add it to the Object
$(this).parent().find('.editablePropertyList .customPropertyPrompt, .editablePropertyList .customPropertyDataType, .editablePropertyList .customPropertyInquirySearchType, .editablePropertyList .customPropertyID, .editablePropertyList .customPropertyText').each(function(index) {
propertyValue = $(this).val();
propertyText = $(this).text();
switch ($(this).attr("class")) {
case "customPropertyID":
propertyRow.propertyID = propertyValue;
break;
case "customPropertyDataType":
propertyRow.dataType = propertyValue;
break;
case "customPropertyPrompt":
propertyRow.prompt = propertyText;
break;
case "customPropertyInquirySearchType":
propertyRow.inquirySearchType = propertyValue;
break;
case "customPropertyText":
// Whenever it reaches this data element, this means
// that the iteration is at the end of a row. Push the
// newly filled propertyRow object (typeof Property) on
// the PropertyTable array. Then reinstance the propertyRow
// object and it will start populating with the next row
// as the next iteration occurs with propertyID
propertyRow.inquirySearchText = propertyValue;
if (propertyRow.inquirySearchText !== "") {
propertyTables.push(propertyRow);
}
propertyRow = {};
break;
}
});
var statusFilter = [];
var limitAnnotation = [];
searchCriteria = {}; // Created the object
searchCriteria.topFolderListBox = topFoldersWithSomeSelected; // Add the List<topLevelFolders> as the first property
searchCriteria.docTypesListBox = docTypesWithSomeSelected; // Add the List<DocumentType> as the second property
searchCriteria.propertyTable = propertyTables; // Add the List<Property> as the third property
searchCriteria.statusFilter = statusFilter; // Add the List<statusFilter> as the fourth property
searchCriteria.limitAnnotation = limitAnnotation; // Add the List<limitAnnotation> as the fifth property
searchCriteria.fromDate = ""; // Add the string fromDate as the sixth property
searchCriteria.toDate = ""; // Add the string toDate as the seventh property
searchCriteria.dateRangeRelativeToday = false;
searchCriteria.annotationText = ""; // Add the string annotationText as the eigth and final property
// Convert to JSON String - craps out here with circular reference error
textToSend = JSON.stringify(searchCriteria, null, "");