JSFiddle - React, Tailwind, and code Playground
HTML
<div id='store'></div>
<div id='log'></div>
JavaScript
dojo.require("dojo.data.ItemFileWriteStore");
var store = null;
function getItem(id) {
store.fetchItemByIdentity({
identity: id,
onItem: function (item, request)
{
var v = store.getValue(item, 'value');
console.log(item, "ITEM");
console.log(v, "VVVVV");
dojo.byId('log').innerHTML = 'getItem(' + id + ') =' + v;
}
});
}
dojo.ready(function () {
var items = [];
for (var p = 0; p < 5; p++) {
items.push({
id: p,
value: 'v ' + p
});
}
console.log(items, "Items");
store = new dojo.data.ItemFileWriteStore({
data: {
identifier: 'id',
items: items
}
});
console.log(store, "store");
var gotList = function (items, request) {
var itemsList = "<ul>";
dojo.forEach(items, function (i) {
itemsList += '<li> id:' + p + ' = ' + store.getValue(i,
"value") + "</li>";
});
itemsList += '</ul>';
dojo.byId('store').innerHTML = itemsList;
}
var gotError = function (error, request) {
alert("The request to the store failed. " + error);
}
// Invoke the search
store.fetch({
onComplete: gotList,
onError: gotError
});
console.log(store, "store");
getItem('2');
});