testing partial rewrite to new_task()
This commit is contained in:
parent
507c22c116
commit
2594301414
@ -15,12 +15,17 @@ function check(id) {
|
||||
|
||||
function new_task() {
|
||||
let input = $("#new-task-input");
|
||||
$.post("/v1/new", {api_key: API_KEY, content: input.val()}, function(data, status) {
|
||||
if (status == "success") {
|
||||
$("#new-task").before("<li><input type='checkbox' id='task-" + data.task.id + "' onchange='check(" + data.task.id + ")'> " + data.task.content + "</li>");
|
||||
} else {
|
||||
console.log(data); // NOTE TEMPORARY (need to handle errors better)
|
||||
}
|
||||
let template = $("#task-template").html();
|
||||
template = $(template);
|
||||
$.post("/v1/new", {api_key: API_KEY, content: input.val()}, function(data) {
|
||||
// $("#new-task").before("<li><input type='checkbox' id='task-" + data.task.id + "' onchange='check(" + data.task.id + ")'> " + data.task.content + "</li>");
|
||||
let input = $("input", template);
|
||||
input.prop("id", "task-" + data.task.id);
|
||||
input.prop("onchange", "check('" + data.task.id + "')");
|
||||
input.after(data.task.content); // not sure if will work
|
||||
})
|
||||
.fail(function(request) {
|
||||
// TODO handle error
|
||||
});
|
||||
input.val("");
|
||||
return false; // prevent form submission
|
||||
@ -32,12 +37,13 @@ function new_api_key() {
|
||||
$.get("/v1/key/new", function(data) {
|
||||
$("code", template).text(data.api_key.key);
|
||||
$("#new-api-key").before(template);
|
||||
}).fail(function() {
|
||||
$("code", template)
|
||||
.css("background-color", "red")
|
||||
.css("color", "white")
|
||||
.text(this.responseJSON.errors.join(" "));
|
||||
$("#new-api-key").before(template);
|
||||
})
|
||||
.fail(function(request) {
|
||||
$("code", template)
|
||||
.css("background-color", "red")
|
||||
.css("color", "white")
|
||||
.text(request.responseJSON.errors.join(" "));
|
||||
$("#new-api-key").before(template);
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user