Monday, 15 September 2014

javascript - getItemByFileId undefined in onSubmitted with FineUploader -



javascript - getItemByFileId undefined in onSubmitted with FineUploader -

i'm working off angularjs example

at point, uploads working (to s3), onsubmit callback exploding: [fine uploader 5.0.2] caught exception in 'onsubmitted' callback - undefined not function

this may cofeescript fat arrow problem, since transpiled illustration coffeescript build environment (and preference coffeescript), i'm stumped anyhow.

here's relevant dict options.

callbacks: { onsubmitted: (id, name) => console.log "calling onsubmitted(#{id}, #{name})" console.log "this shouldn't undefined: #{@getitembyfileid}" # _is_ undefined $file = $(@getitembyfileid(id)) console.log $file $thumbnail = $file.find(".qq-thumbnail-selector") $thumbnail.click -> openlargerpreview( $scope, $(element), largepreviewsize, id, name ) homecoming homecoming }

here's skinny arrow version (see comments below) rendered js:

callbacks: { onsubmitted: function(id, name) { var $file, $thumbnail; console.log("calling onsubmitted(" + id + ", " + name + ")"); $file = $(getitembyfileid(id)); console.log($file); $thumbnail = $file.find(".qq-thumbnail-selector"); $thumbnail.click(function() { openlargerpreview($scope, $(element), largepreviewsize, id, name); }); } }

the result (when upload something)

[fine uploader 5.0.2] received 1 files or inputs. [fine uploader 5.0.2] attempting validate image. calling onsubmitted(0, imag0161.jpg) shouldn't undefined: undefined [fine uploader 5.0.2] caught exception in 'onsubmitted' callback - undefined not function

as indicated in code, problem (as understand it) @getitembyfileid not defined on this properly, (again, understand it) this should fineuploaders3 object.

there's no need utilize fat arrow in fine uploader event handlers. context of event handler set fine uploader instance (by fine uploader). utilize "skinny arrow".

javascript coffeescript this fine-uploader

No comments:

Post a Comment