Skip to content
Permalink
Browse files

fixed openlist bug

  • Loading branch information...
hauptpas committed May 21, 2018
1 parent d76ae63 commit 5a77ec6ef1e700b0557a102ff9bb2d902c929050
Showing with 10 additions and 11 deletions.
  1. +3 −2 src/Demo.js
  2. +3 −6 src/Task.js
  3. +4 −3 src/TaskList.js
@@ -48,8 +48,9 @@ $(function () {
$('#openList').click(function (event) {
var listId = prompt("Bitte geben Sie die Tasklisten ID an", "demo");
if (listId != null) {
TaskList.load(listId, function (taskList) {
$('#taskList').html(taskList.render());
TaskList.load(listId, function (tl) {
taskList = tl;
$('#taskList').html(tl.render());
});
}
});
@@ -25,14 +25,11 @@ Task.prototype.render = function () {
'class': 'input-field inline'
}).append($title);

$markup = $('<li>').append([$label, $textInputWrapper]);
$markup = $('<li>', {
'class': this.done? 'finished' : ''
}).append([$label, $textInputWrapper]);

// TODO: connect object instance to data attribute 'task'
$markup.data('task', this);
// TODO: react on change of the checkbox and the input field:
// - populate done field from checkbox
// - populate title field from input text field
// - write new value using console.log
$markup.find('input').change(function (event) {
var taskObject = $(this).closest('li').data("task");
taskObject.done = $done.is(":checked");
@@ -51,12 +51,13 @@ TaskList.prototype.save = function () {
TaskList.load = function (id, callback) {
var taskList = new TaskList();
$.getJSON('http://zhaw.herokuapp.com/task_lists/' + id, function (returnedData) {
taskList.id = returnedData.id;
$.each(returnedData.tasks, function (index, task) {
taskList.id = returnedData.id;
taskList.title = returnedData.title;
$.each(returnedData.tasks, function (index, task) {
var t = taskList.createTask(task.title);
t.done = task.done;
});
taskList.title = returnedData.title;
window.location.hash = taskList.id;
callback(taskList);

});

0 comments on commit 5a77ec6

Please sign in to comment.
You can’t perform that action at this time.