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);
|
||||
}
|
||||
// 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 FD = new FormData(playlistAddForm);
|
||||
|
||||
// https://stackoverflow.com/questions/48322876/formdata-doesnt-include-value-of-buttons
|
||||
FD.append('action', 'add');
|
||||
|
||||
@ -168,10 +178,7 @@
|
||||
XHR.send(FD);
|
||||
}
|
||||
|
||||
playlistAddForm.addEventListener('submit', function(event){
|
||||
event.preventDefault();
|
||||
sendData();
|
||||
});
|
||||
playlistAddForm.addEventListener('submit', sendData);
|
||||
</script>
|
||||
{% endif %}
|
||||
</header>
|
||||
|
Loading…
x
Reference in New Issue
Block a user