Hi, I'm deploying a node with and array like a default property but when I try to deploy the node I can't access to the info in the js file (I have a empty array there).
This is the definition:
defaults:{
name: {value:""},
...
fiware_attrs_array: {value:[ ]},
},
Oneditprepare and oneditsave:
oneditprepare: function(){
var node = this;
$("#node-input-fiware_attrs_array").editableList({
addItem: function(container, i, attr){
if (node.fiware_attrs_array.length > 0){
for(var x=0; x < this.fiware_attrs_array.length; x++){
var item = this.item[x];
console.log(item);
}
}else if (node.fiware_attrs_array.length == 0){
var newItem = $('<li>', {for:"node-input-attr"+i}).appendTo(container);
var name = $('<input/>', {id:"node-input-attr-name"+i, type: "text"}).appendTo(newItem);
var type = $('<input/>', {id:"node-input-attr-type"+i, type: "text"}).appendTo(newItem);
var value = $('<input/>', {id:"node-input-attr-value"+i, type: "text"}).appendTo(newItem);
}
},
removeItem: function(container){
},
sortable: true,
removable: true
});
},
oneditsave: function(){
var attrs = $("#node-input-fiware_attrs_array").editableList('items');
var node = this;
var array = [];
attrs.each(function(i){
var attr = $(this);
var attrName = attr.find('#node-input-attr-name'+i).val();
var attrType = attr.find('#node-input-attr-type'+i).val();
var attrValue = attr.find('#node-input-attr-value'+i).val();
var newAttr = {};
newAttr['name'] = attrName;
newAttr['type'] = attrType;
newAttr['value'] = attrValue;
array.push(newAttr);
});
node.fiware_attrs_array = array;
console.log("Attributes: " + JSON.stringify(node.fiware_attrs_array));
}
And the html element:
<div class="form-row node-input-fiware_attrs_array_row">
<ol id="node-input-fiware_attrs_array">
</div>