1
現在、Json入力に基づいてモデルを作成しています。逆も同様です。Jsonオブジェクト値を取得する
問題は、私は、このようなpredefinedStream
、name
とkind
などのオブジェクトを取得しようとすると、最初の二id
とclasses
が正しく警告に表示されているが、それは未定義を示しています。
保存JSON出力
警告メッセージが
負荷要素を生成
私はテキストエリアに、以前に生成されたコードをコピーして、負荷をクリックすると、私はJSON形式で次
警告上記の目的のために
セーブデータ取得オブジェクト
function saveFlowchart() {
var node = [];
var matches = [];
var totalElementCount = 0;
var searchEles = document.getElementById("container").children;
for (var i = 0; i < searchEles.length; i++) {
matches.push(searchEles[i]);
var idOfEl = searchEles[i].id;
totalElementCount = idOfEl;
if (searchEles[i].id != null || searchEles[i].id != "") {
var $element = $("#" + searchEles[i].id);
var dropElem = $("#" + searchEles[i].id).attr('class');
var position = $element.position();
var elId = parseInt(idOfEl);
if (dropElem == "streamdrop ui-draggable") {
node.push({
id: idOfEl,
class: dropElem,
position: {
top: position.top,
left: position.left,
bottom: position.bottom,
right: position.right
}
});
for (var count = 0; count < 100; count++) {
if (createdImportStreamArray[count][0] == idOfEl) {
node.push({
predefinedStream: createdImportStreamArray[count][1],
name: createdImportStreamArray[count][2],
kind: "import"
});
}
}
}
}
}
}
は、この点で、いくつかの入力をお願い申し上げ以前プットが正しく取得されたJSONを保存、私は第一警告ボックス と同様のデータを取得する必要がある場合の要素
function loadFlowchart(e) {
var flowChartJson = $('#jsonOutput').val();
var flowChart = JSON.parse(flowChartJson);
var node = flowChart.node;
$.each(node, function (index, elem) {
droppedElement = document.getElementById(id);
var id = elem.id;
var classes = elem.class;
// var positionTop = elem.position.top;
var asName = elem.name;
var kind = elem.kind;
if (classes == "streamdrop ui-draggable") {
var selectedStream = elem.predefinedStream;
alert("elem id: " + id + "\nclass:" + classes + "\nasName:" + asName + "\nkind:" + kind + "\nselected:" + selectedStream);
if (kind == "import") {
createdImportStreamArray[id - 1][0] = id;
createdImportStreamArray[id - 1][1] = selectedStream;
createdImportStreamArray[id - 1][2] = asName;
createdImportStreamArray[id - 1][3] = "Import";
}
alert("Id of element parsed: " + id + "\nclass: " + classes /*+ "\npositionTop: " + positionTop*/);
var newAgent = $('<div>').attr('id', id).addClass('streamdrop');
var prop = $('<a onclick="doclick(this)"><b><img src="../Images/settings.png" class="settingsIconLoc"></b></a> ').attr('id', (id + '-prop'));
var showIcon = $('<img src="../Images/Import.png" class="streamIconloc"></b></a> ').attr('id', (id));
var conIcon = $('<img src="../Images/connection.png" onclick="connectionShowHideToggle(this)" class="showIconDefined"></b></a> ').attr('id', (id + 'vis'));
newAgent.text(asName).append('<a class="boxclose" id="boxclose"><b><img src="../Images/Cancel.png"></b></a> ').append(showIcon).append(conIcon).append(prop);
dropCompleteElement(newAgent, id, e, kind);
}
});
}
を作成するために、JSONオブジェクトの値を取得します。
あなたの 'json'ブロックのどこにでも' undefined'を見つけることができません! –
あなたのflowChartJson Jsonは少し疑わしいですね。 Jsonのフォーマットについてはこちらをご覧ください - https://www.copterlabs.com/json-what-it-ishow-it-works-how-to-use-it/ – Tasos