1
0
mirror of https://gitlab.crans.org/bde/nk20 synced 2024-11-30 04:13:01 +00:00
nk20/static/js/alias.js

38 lines
1.0 KiB
JavaScript
Raw Normal View History

2020-03-26 22:05:08 +00:00
$("#alias_input").on('keypress',function(e) {
if(e.which == 13) {
$("#alias_submit").click();
}
});
function create_alias(note_id){
$.post("/api/note/alias/",
{
"csrfmiddlewaretoken": CSRF_TOKEN,
"name": $("#alias_input").val(),
"note": note_id
}
).done(function(){
2020-07-30 13:49:59 +00:00
$("#alias_table").load(location.pathname+ " #alias_table");
2020-03-26 22:05:08 +00:00
addMsg("Alias ajouté","success");
})
.fail(function(xhr, textStatus, error){
errMsg(xhr.responseJSON);
});
}
// on click of button "delete" , call the API
function delete_button(button_id){
$.ajax({
url:"/api/note/alias/"+button_id+"/",
method:"DELETE",
headers: {"X-CSRFTOKEN": CSRF_TOKEN}
})
.done(function(){
addMsg('Alias supprimé','success');
2020-07-30 13:49:59 +00:00
$("#alias_table").load(location.pathname + " #alias_table");
2020-03-26 22:05:08 +00:00
})
.fail(function(xhr,textStatus, error){
errMsg(xhr.responseJSON);
});
}