jonasundderwolf / django-image-cropping

Django helper application to easily and non-destructively crop arbitrarily large images in admin and frontend.
Other
553 stars 131 forks source link

BUG: jQuery loss (can't use jQuery after import image_cropping.js) #69

Closed FedeG closed 9 years ago

FedeG commented 9 years ago

Can't use jQuery after: "jQuery.noConflict(true)(function() {image_cropping.init();}); " in: https://github.com/jonasundderwolf/django-image-cropping/blob/master/image_cropping/static/image_cropping/image_cropping.js

FedeG commented 9 years ago

Because "jQuery.noConflict(true)" overwrites $ and jQuery with previous version. The correct usage is jQuery.noConflict() directly

View details in: http://sundropsoftware.com/how-to-use-jquery-noconflict-the-right-way/

anrie commented 9 years ago

There is an older issue (#19) concerning the same subject.

All we do is to remove the jQuery that we included to make the widget work. So you shouldn't rely on this jQuery version for anything you do in the admin. Nevertheless django.jQuery and every jQuery you included separately should stay intact.

The only potential problem I can see is the recently added option to make Image Cropping NOT include its own jQuery version: https://github.com/jonasundderwolf/django-image-cropping#custom-jquery Have you eventually set IMAGE_CROPPING_JQUERY_URL to None?

FedeG commented 9 years ago

Yes, i tried to configure the IMAGE_CROPPING_JQUERY_URL to None but neither worked.

Additionally, i tried to configure the IMAGE_CROPPING_JQUERY_URL with a valid url jQuery and load jQuery after but neither worked.

anrie commented 9 years ago

I can see the issue in the first case and we'll look into it.

Concerning the second case: As I said, this is the intended behaviour. Either you include another jQuery yourself or you use Django's jQuery which is available as django.jQuery

RaphaelKimmig commented 9 years ago

I'm having the same issue. Using jquery.noconflict removes the existing jquery. When combined with IMAGE_CROPPING_JQUERY_URL = None this means no more jquery for me :-(

anrie commented 9 years ago

@RaphaelKimmig Yes, I can see the issue. There should be a check in image_cropping.js if IMAGE_CROPPING_JQUERY_URL was set to None and if this is the case, we shouldn't use .noConflict() so the JQuery provided by the user is left intact.

However I start thinking that the None-Option was maybe not best idea in the first place and we should simply restore the old behavior.

anrie commented 9 years ago

@RaphaelKimmig Can you check if this solves your problem: https://github.com/jonasundderwolf/django-image-cropping/tree/issue69/jquery_url?

RaphaelKimmig commented 9 years ago

@anrie Indeed it does. Thank you very much :-)

On another note - when installing django-image-cropping directly from git (via setup.py install) the static files are not included in the app folder. I noticed they are not listed in the manifest. Is that a bug or am I doing something wrong here?

anrie commented 9 years ago

Okay, there is a new release (1.0.2) that should solve this issue.

@RaphaelKimmig The static files should now be included if you install directly from Github.

RaphaelKimmig commented 9 years ago

@anrie Awesome, thank you!