这里使用自定义的JSON数据是我输入JSON数据文件的一部分:在jstree形式
{
"id": "ns=2:s=Configured Tags",
"text": "Configured Tags",
"path": "Configured Tags",
"children": [
{
"id": "ns=2:s=[System]",
"text": "System",
"path": "Configured Tags/System",
"children": [
{
"id": "ns=2:s=[System]Gateway",
"text": "Gateway",
"path": "Configured Tags/System/Gateway",
"children": []
}]
}]
}
这里我有自定义字段path
,但我需要一些其他类似的dataType等
我想要返回作为我的表单的输入值的自定义fields
的串联字符串。
这里是我的形式和jstree脚本部分:
<form id="form" action="/opc_add_data" method="post">
<div id="tree"></div>
<br>
<button class="btn-flat inverse pull-right" name="submit" id="submit" onclick="return confirm('Are you sure?')" type="submit">Confirm</button>
</form>
$('#form').submit(function() {
var data = $('#tree').jstree(true).get_bottom_selected(true);
for(var count = 0; count < data.length; count++){
$(this).append('<input type="text" name="' + data[count]["id"] + '" value="' + data[count]["path"] + '" hidden/>');
}
return true;
});
我的形式过程的一部分(Python2.7):
for key in request.form.keys():
if key != "submit":
description.append(re.sub('[^a-zA-Z0-9 \n.]', '_', request.form.get(key)))
如果我试图让data[count]["id"]
和data[count]["text"]
我成功了,因为text
和id
是the doc中描述的字段。但是当我尝试用我的习惯时,我得到"undefined"
作为价值。
我的问题是:我真的可以做我想做的事,即以这种方式获得自定义字段data[count]["path"]
?