У меня возникли проблемы с получением поля createdAt в javascript/html с использованием синтаксического анализа. Вот как я показываю текущие поля в HTML. Для справки, оригинальный учебник я получил от этого здесь: http://code.tutsplus.com/tutorials/getting-started-with-parse--net-28000Parse.com retrieve createdAt поле Javascript
<script id="todo-items-template" type="x/handlebars">
<table id="data">
<tr><td class="first">Rank</td>
<td class="second"> <li class="list-item"><input type="checkbox" id="{id}">{content}</li></td>
<td class="third" ><li class="list-item"><output type="date" id="{id}">{createdAt}</li></td>
</tr>
</table>
</script>
А вот как я спасаю его в JavaScript. Когда веб-страница отображается, содержимое является правильным, но поле createdAt просто показывает {createdAt}. Как вы можете видеть ниже, я попытался получить его непосредственно после того, как я его сохранил, но не повезло. Я также попытался включить его в запрос, а также не повезло. Я чувствую, что, возможно, я пытаюсь отобразить его неправильно.
//Handle Click Event
submitBtn.on('click', function(e) {
//Save the current Todo
var text = Y.one('#list-input').get('value');
var ListItem = Parse.Object.extend("ListItem");
var listItem = new ListItem();
listItem.set("content", text);
listItem.set("isComplete", false);
//Once it is saved, show it in the list of todo's.
listItem.save(null, {
success: function(item) {
noTasksMessage.addClass('hidden');
var content = Y.Lang.sub(Y.one('#todo-items-template').getHTML(), {
content: item.get('content'),
id: item.id,
});
incompleteItemList.append(content);
input.set('value', '').focus();
},
error: function(gameScore, error) {
alert("Error when saving Todos: " + error.code + " " + error.message);
}
});
var createdAt = listItem.createdAt;
});
И, наконец, вот как я извлечения мои разбора объектов:
//Get 10 most recent incomplete Todos.
ListItem = Parse.Object.extend("ListItem");
query = new Parse.Query(ListItem);
query.equalTo('isComplete', false)
query.limit = 10;
query.descending('createdAt');
query.find({
success: function(results) {
if (results.length > 0) {
noTasksMessage.addClass('hidden');
}
//Append each of the incomplete tasks to the Incomplete List
Y.Array.each(results, function(val, i, arr) {
var content = Y.Lang.sub(Y.one('#todo-items-template').getHTML(), {
content: val.get('content'),
id: val.id,
isComplete: false
});
incompleteItemList.append(content);
});
//When the checkbox is clicked for any of the items in the incomplete list, update it as complete.
incompleteItemList.delegate('click', function (e) {
var self = this;
query = new Parse.Query(ListItem);
query.get(self.one('input').get('id'), {
success: function(item) {
item.set('isComplete', true);
item.save();
self.remove();
if (incompleteItemList.all('li').size() >= 1) {
noTasksMessage.removeClass('hidden');
}
},
error: function(object, error) {
alert("Error when updating todo item: " + error.code + " " + error.message);
}
});
}, 'li');
},
error: function(error) {
alert("Error when retrieving Todos: " + error.code + " " + error.message);
}
});