p._initEvents = function() {
$(window).on('drop', this.onDrop.bind(this)).on('dragover', this.onDragOver);
};
p.onDrop = function(e) {
e.preventDefault();
var files = e.originalEvent.dataTransfer.files;
$.each(files, function(index, file){
this.showTemplate();
});
};
p.showTemplate = function() {
console.log('show template');
};
I'm trying to run this.showTemplate() but the error says it's undefined, I believe it's to do with binding this.
I have bound this for the onDrop method, but I'm not sure the best way to access this inside a loop?