我使用 AlloyUI 表单构建器构建了一个动态表单。我想捕获我在边界框中拖放的元素。我遇到了这样的事情:
函数 saveFieldsForm(){
var formXML = '';
myFormBuilder.get('fields').each(
function(item, index, collection) {
var dataType = item.get('dataType'),
indexType = item.get('indexType'),
label = item.get('label'),
multiple = item.get('multiple'),
name = item.get('name'),
options = item.get('options'),
readOnly = item.get('readOnly'),
repeatable = item.get('repeatable'),
required = item.get('required'),
showLabel = item.get('showLabel'),
type = item.get('type'),
tip = item.get('tip'),
predefinedValue= item.get('predefinedValue'),
width = item.get('width');
var fieldXML = '<field>';
fieldXML += '<type>' + type + '</type>';
fieldXML += '<name>' + name + '</name>';
fieldXML += '<required>' + required + '</required>';
fieldXML += '<tip>' + tip + '</required>';
fieldXML += '<predefinedValue>' + predefinedValue + '</predefinedValue>';
fieldXML += '</field>';
alert("fieldXML: "+ fieldXML);
formXML += fieldXML;
});
formXML += '</root>';
alert("formXML: "+ formXML);
AUI().use('aui-io-request',
function(A) {
A.io.request(
'<%=ajaxURL%>',{
data: {
formXML : formXML,
},
dataType: 'json',
on: {
success: function(data) {
alert("Your form has been saved!")
},
error: function(jqXHR, textStatus, errorThrown) {
alert("Error, the content has not been saved! Please try again...");
console.log(textStatus, errorThrown);
}
}
});
});
}
在上面的代码中,我了解拖放字段正在被捕获,但我不了解第二行代码中函数内部的项目、索引和集合字段。这些值是什么?这些值是从哪里填充的?请帮忙!!!