I tried to do a what described in https://api.drupal.org/comment/56868#comment-56868, but for Drupal 8.
Drupal.behaviors.corsFileAutoUpload = {
attach: function (context) {
$(context).find('input[type="file"].s3fs-cors-upload').once('auto-s3file-upload').on('uploadToS3', Drupal.s3fs_cors.uploadToS3);
},
}
To invoke this from PHP, I used the following code.
$response->addCommand(new InvokeCommand($selector, 'uploadToS3');
But I got an error from core/misc/ajax.js line number of 1266, as the method for the element is not available. On inspecting eventlistener in Chrome, it was very well visible and I was also able to fire it from Browser Console.
I am missing something here. How do we call a custom jQuery function using InvokeCommand
?