Reputation: 40084
I am trying to understand this line of code. it's from the blueimp jquery file upload. I've extracted the part I need down this line (it populates my page with images I already have). I am unclear as to why it needs to be called this way. I understand the call() method, just not clear on this - it seems extra convoluted:
$('#fileupload').fileupload('option', 'done').call($('#fileupload'), null, {result: data.images});
data.images is a JSON set of images. The code works, just unclear why I need to call things as they are.
Here's the original code - made for multiple fields it looks like)
https://github.com/blueimp/jQuery-File-Upload/blob/master/js/main.js#L53
Upvotes: 0
Views: 108
Reputation: 55392
$('#fileupload').fileupload('option', 'done')
reads the value of the done
option, which appears to be a callback function. As the function is not being invoked as a property of the $('#fileupload')
element, the code has to call
it so as to give it the expected value for this
.
Upvotes: 1