diff --git a/static/js/alias.js b/static/js/alias.js new file mode 100644 index 00000000..267410da --- /dev/null +++ b/static/js/alias.js @@ -0,0 +1,37 @@ + + $("#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(){ + $("#alias_table").load(location.href+ " #alias_table"); + 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'); + $("#alias_table").load(location.href + " #alias_table"); + }) + .fail(function(xhr,textStatus, error){ + errMsg(xhr.responseJSON); + }); + } diff --git a/templates/member/club_alias.html b/templates/member/club_alias.html index 394b1c95..4b6f2882 100644 --- a/templates/member/club_alias.html +++ b/templates/member/club_alias.html @@ -4,3 +4,7 @@ {% block profile_content %} {% include "member/alias_update.html" %} {% endblock %} + +{% block extrajavascript %} + +{% endblock%} diff --git a/templates/member/profile_alias.html b/templates/member/profile_alias.html index 9d2c34a3..eb6e499a 100644 --- a/templates/member/profile_alias.html +++ b/templates/member/profile_alias.html @@ -6,35 +6,5 @@ {% endblock %} {% block extrajavascript %} - + {% endblock%}