dynatable を試していますが、問題が発生しています。異なる json ファイルからレコードを更新する方法がわかりません。
私のHTML本文:
<input type="button" value="items a" id="setToItemsA"><br>
<input type="button" value="items b" id="setToItemsB"><br>
<br><br>
<table id="my-final-table">
<thead>
<th>Band</th>
<th>Song</th>
</thead>
<tbody>
</tbody>
</table>
私のスクリプト
$(document).ready(function() {
var json1 = [
{
"band": "Weezer",
"song": "El Scorcho"
},
{
"band": "Chevelle",
"song": "Family System"
}
];
var json2 = [
{
"band": "Band1",
"song": "Song1"
},
{
"band": "Band2",
"song": "Song2"
}
];
$('#my-final-table').dynatable({
dataset: {
records: json1
}
});
$('#setToItemsA').click(
function() {
setToItems(json1);
});
$('#setToItemsB').click(
function() {
setToItems(json2);
});
function setToItems (argument) {
console.log(argument);
$('#my-final-table').dynatable({
dataset: {
records: argument
}
});
}
});
テーブルのバインドを解除して、新しいデータセットでやり直そうとしましたが、うまくいきませんでした。正直なところわかりません。ご協力いただきありがとうございます!