blueimp/jQuery-File-Upload — Issue #986: Issue with loadImage function
Author: preziusoftware
Created: 2012-02-02 21:08:08+00:00
State: open

When using jQuery File Upload in a XHR-loaded content and not using jQuery template engine (I mean tmpl), I got this error
```
Uncaught TypeError: undefined is not a function
$.widget._renderUpload
jQuery.extend.eachjquery.js:658
jQuery.fn.jQuery.eachjquery.js:271
$.widget._renderUpload
$.widget.options.add
a.Widget._triggerjquery-ui.min.js:9
$.widget._onAdd
jQuery.extend.eachjquery.js:658
$.widget._onAdd
$.widget._onChange
jQuery.event.dispatchjquery.js:3256
jQuery.event.add.elemData.handle.eventHandle
```
So shortly I found out that the plugin wasn't assigning as global the loadImage function and that the plugin used to throw the exception at line 328, so I did a little workaround to this issue by editing this
```
loadImage(
files[index],
function (img) {
$(node).append(img);
// Force reflow:
that._reflow = that._transition &&
node.offsetWidth;
$(node).addClass('in');
},
{
maxWidth: options.previewMaxWidth,
maxHeight: options.previewMaxHeight,
canvas: options.previewAsCanvas
}
);
```
into this
```
window.loadImage(
files[index],
function (img) {
$(node).append(img);
// Force reflow:
that._reflow = that._transition &&
node.offsetWidth;
$(node).addClass('in');
},
{
maxWidth: options.previewMaxWidth,
maxHeight: options.previewMaxHeight,
canvas: options.previewAsCanvas
}
);
```
Now, I see this is just a rude workaround, and I actually don't know if I'm doing anything wrong, so could you please take a look at this problem?