Fix regression: Can't remove videos from local playlists
This commit is contained in:
parent
fd327ae653
commit
b614fcdb85
@ -142,9 +142,19 @@
|
|||||||
window.setTimeout(removeMessage, removalDelay+300, messageBox);
|
window.setTimeout(removeMessage, removalDelay+300, messageBox);
|
||||||
}
|
}
|
||||||
// https://developer.mozilla.org/en-US/docs/Learn/HTML/Forms/Sending_forms_through_JavaScript
|
// https://developer.mozilla.org/en-US/docs/Learn/HTML/Forms/Sending_forms_through_JavaScript
|
||||||
function sendData(){
|
function sendData(event){
|
||||||
|
var clicked_button = document.activeElement;
|
||||||
|
if(clicked_button === null || clicked_button.getAttribute('type') !== 'submit' || clicked_button.parentElement != event.target){
|
||||||
|
console.log('ERROR: clicked_button not valid');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(clicked_button.getAttribute('value') !== 'add'){
|
||||||
|
return; // video(s) are being removed from playlist, just let it refresh the page
|
||||||
|
}
|
||||||
|
event.preventDefault();
|
||||||
var XHR = new XMLHttpRequest();
|
var XHR = new XMLHttpRequest();
|
||||||
var FD = new FormData(playlistAddForm);
|
var FD = new FormData(playlistAddForm);
|
||||||
|
|
||||||
// https://stackoverflow.com/questions/48322876/formdata-doesnt-include-value-of-buttons
|
// https://stackoverflow.com/questions/48322876/formdata-doesnt-include-value-of-buttons
|
||||||
FD.append('action', 'add');
|
FD.append('action', 'add');
|
||||||
|
|
||||||
@ -168,10 +178,7 @@
|
|||||||
XHR.send(FD);
|
XHR.send(FD);
|
||||||
}
|
}
|
||||||
|
|
||||||
playlistAddForm.addEventListener('submit', function(event){
|
playlistAddForm.addEventListener('submit', sendData);
|
||||||
event.preventDefault();
|
|
||||||
sendData();
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</header>
|
</header>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user