scottcheng / cropit

A "customizable crop and zoom" jQuery plugin.
http://scottcheng.github.io/cropit/
MIT License
874 stars 307 forks source link

cropit Cannot read property 'push' of undefined #310

Open nargessmi87 opened 3 years ago

nargessmi87 commented 3 years ago

I get this error :

Uncaught TypeError: Cannot read property 'push' of undefined at Cropit.init (jquery.cropit.js:274) at new Cropit (jquery.cropit.js:194) at HTMLDivElement. (jquery.cropit.js:102) at Function.each (app.js?id=79f598946b8ba4ad1fb4:15693) at jQuery.fn.init.each (app.js?id=79f598946b8ba4ad1fb4:15515) at jQuery.fn.init.init (jquery.cropit.js:96) at jQuery.fn.init._jquery2.default.fn.cropit (jquery.cropit.js:147) at HTMLDocument. (app.js?id=79f598946b8ba4ad1fb4:10447) at mightThrow (app.js?id=79f598946b8ba4ad1fb4:19074) at process (app.js?id=79f598946b8ba4ad1fb4:19142)

here is the script:

$('.image-editor').cropit({
  imageState: {
    src: 'http://lorempixel.com/500/400/',
  },
});

$('.rotate-cw').click(function() {
  $('.image-editor').cropit('rotateCW');
});
$('.rotate-ccw').click(function() {
  $('.image-editor').cropit('rotateCCW');
});

$('.export').click(function() {
  var imageData = $('.image-editor').cropit('export');
  window.open(imageData);
});

and the html:

Resize image
    </div>

how can i fix this

SebastienGautier commented 3 years ago

You're probably using jQuery 3+ Cropit seems to be compatible with jQuery 2 only

Adding jQuery Migrate should fix your issue