liquid_feedback_frontend

diff static/js/xhr.js @ 1618:2f9e1e882de6

Add/remove interest via fetch
author bsw
date Mon Feb 01 23:43:54 2021 +0100 (2021-02-01)
parents
children 62856200414d
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/static/js/xhr.js	Mon Feb 01 23:43:54 2021 +0100
     1.3 @@ -0,0 +1,21 @@
     1.4 +function toggleInterest(issue_id, iconElId) {
     1.5 +  var iconEl = document.getElementById(iconElId);
     1.6 +  var interested = iconEl.innerHTML == "star_outline";
     1.7 +  
     1.8 +  var data = new FormData();
     1.9 +  data.append("issue_id", issue_id);
    1.10 +  data.append("interested", interested);
    1.11 +
    1.12 +  fetch("/lf/interest/xhr_update", {
    1.13 +      method : "POST",
    1.14 +      body: data
    1.15 +  }).then(
    1.16 +      response => {
    1.17 +        if (response.status == 200) {
    1.18 +          iconEl.innerHTML = interested ? "star" : "star_outline";
    1.19 +        }
    1.20 +      }
    1.21 +  );
    1.22 +
    1.23 +}
    1.24 +

Impressum / About Us