Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught TypeError: undefined is not a function for $('#cropbox').Jcrop in crop.html.erb file. #4

Open
krunalinnovify opened this issue Apr 15, 2015 · 2 comments

Comments

@krunalinnovify
Copy link

@peterberkenbosch , When i am using Cropping functionality in Spree eCommerce using gem "spree_image_cropper" from https://github.com/pero-ict-solutions/spree_image_cropper link.

Version i use.

Rails 4.2.0
Spree 3-0-stable

I use gem .
gem 'spree', github: 'spree/spree', branch: '3-0-stable'
gem 'spree_gateway', github: 'spree/spree_gateway', branch: '3-0-stable'
gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: '3-0-stable'
gem "spree_image_cropper", :git => "git://github.com/pero-ict-solutions/spree_image_cropper.git"

when i want to do cropping at that time there is no cropping tool and it gives error.

Uncaught TypeError: undefined

I also post in stack overflow.

http://stackoverflow.com/questions/29647794/uncaught-typeerror-undefined-is-not-a-function-for-cropbox-jcrop

@kennyadsl
Copy link

I think the installer paths is wrong here: https://github.com/pero-ict-solutions/spree_image_cropper/blob/master/lib/generators/spree_image_cropper/install/install_generator.rb#L5-L11

It should add assets requires into something like vendor/assets/javascripts/spree/backend/all.js instead.

@krunalinnovify to quickly fix the issue just add this line into your application vendor/assets/javascripts/spree/backend/all.js:

//= require spree/backend/spree_image_cropper

and this one into your vendor/assets/stylesheets/spree/backend/all.css:

*= require spree/backend/spree_image_cropper

If this work can you please provide a Pull Request to fix installer paths? 🍻

@krunalinnovify
Copy link
Author

@kennyadsl , Your ans is Right, But it's still not work. I have fixed issue.

Step 1 ) Download Code From below link.

https://github.com/pero-ict-solutions/spree_image_cropper

Step 2 ) Downloaded code put in home dir with unzip file.

/home/PC-Name/spree_image_cropper/lib/generators/spree_image_cropper/

Step 3) Open “install_generator.rb” file.

Replace this code with respectively method.

def add_javascripts 
             append_file 'vendor/assets/javascripts/spree/backend/all.js', "//= require               spree/backend/spree_image_cropper\n" 
  end 

  def add_stylesheets 
    inject_into_file 'vendor/assets/stylesheets/spree/backend/all.css', " *= require spree/backend/spree_image_cropper\n", before: /\*\//, verbose: true 
  end 

Step 4) Add gem "spree_image_cropper" in gem file with local url.

For Example

gem "spree_image_cropper", :path => "/home/pc-name/spree_image_cropper"

And I create a fork from "pero-ict-solutions/spree_image_cropper" and changes in my fork and i have create a new pull request to "pero-ict-solutions" .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants