I think you are missing the arrow notation
Function ( (event) => { … });
Or something in this style. Otherwise you loose context.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I'm creating a webcam recorder for my application using Alpine. I got most of the things working as expected, except that Chrome throws error for the following block of code -
toggleRecordingStatus() {
if(this.mediaRecorder.state === "inactive")
{
this.recordingStatus = "Stop Recording";
this.recordedBlobs = [];
this.mediaRecorder.start()
// Following block throws error. Apparantly "this' ain't working right.
this.mediaRecorder.ondataavailable = function(event) {
this.recordedBlobs.push(event.data);
};
}
Error thrown in console -
Uncaught TypeError: Cannot read properties of undefined (reading 'push')
at mediaRecorder.ondataavailabl
Can someone help me fix this, please?
I think you are missing the arrow notation
Function ( (event) => { … });
Or something in this style. Otherwise you loose context.
Please or to participate in this conversation.