koorgoo / ngCropper

AngularJS wrapper for https://github.com/fengyuanchen/cropper
107 stars 72 forks source link

Error when not specifying 'build' option #29

Open cphyc opened 8 years ago

cphyc commented 8 years ago

When not declaring 'build' option, cropper is unable to attach the build event and therefore returns a window object, that cannot be triggered:

The line that fails is this one:

$this.one(EVENT_BUILD, options.build).trigger(buildEvent);)

it throws the error:

TypeError: $this.one(...).trigger is not a function
    at Cropper.prototype.load (ngCropper.all.js:formatted:258)
    at new Cropper (ngCropper.all.js:formatted:230)
    at HTMLImageElement.<anonymous> (ngCropper.all.js:formatted:2201)
    at Function.jQuery.extend.each (jquery.js:360)
    at jQuery.fn.jQuery.each (jquery.js:137)
    at $.fn.cropper (ngCropper.all.js:formatted:2195)
    at ngCropper.all.js:formatted:2249
    at processQueue (angular.js:14745)
    at angular.js:14761
    at Scope.$eval (angular.js:15989)

You should replace the options.build by options.build || function() {}.

cphyc commented 8 years ago

There is also the error with a missing options.built function.