shopping-list/bin/list.js

30 lines
868 B
JavaScript
Raw Normal View History

2018-10-24 15:00:27 +02:00
$(document).ready(function(){
$(".check").change(function(){
var dataId = $(this).parent().data("id");
$.ajax({
type: "POST",
2018-11-20 09:59:59 +01:00
url: "api/list/check",
2018-10-24 15:00:27 +02:00
data: {
id: dataId,
status: $(this).prop("checked")
},
2018-11-14 16:25:50 +01:00
success: function(){infoPopUp("SAVED!", 100);},
error: function(){infoPopUp("Netzwerkfehler! Bitte aktualisieren.", 100);}
2018-10-24 15:00:27 +02:00
});
if($(this).prop("checked")){$("[data-id='"+dataId+"']").addClass("checked");}
else{$("[data-id='"+dataId+"']").removeClass("checked");}
});
$("#remove").click(function(){
$.ajax({
type: "POST",
2018-11-20 09:59:59 +01:00
url: "api/list/del",
2018-10-24 15:00:27 +02:00
success: function(){
location.reload();
}
});
});
$("#nameField").focus();
$("#anzahl").on("focus", function(){$(this).select();});
$("#nameField").on("focus", function(){$(this).select();});
});