Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7562477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T13:25:03+00:00 2026-05-30T13:25:03+00:00

How do I correctly access an object once it has been instantiated : Im

  • 0

How do I correctly access an object once it has been instantiated :

Im implementing jCrop and need to run it twice on the page – (first time sets a default box & second sets the box in the middle of the image)

So I need to create the jCrop object and be able to access its properties later, here is my code so far :

    var myJcrop;
if (cropperInit == true) {
    getjCropSize();

    //Start up jCrop on the image, specifying our function be called when the selection rectangle changes,
    myJcrop = image.Jcrop({
        setSelect: [10, 10, 50, 50],
        aspectRatio: 1,
        onChange: update,
        onSelect: update,
        bgFade: 'true'
    });
} else {
    alert("cropperInit = false");
    myJcrop({
        setSelect: [startX, startY, boxWH, boxWH],
        aspectRatio: 1,
        onChange: update,
        onSelect: update,
        bgFade: 'true'
    });
}

The jCrop object is created OK in the first ‘if block’ but the second ‘else if’ block isn’t working.

EDIT:

After digging about, jCrop has an API for this, its used like this :

var jCropApi;
image.Jcrop({
    setSelect: [10, 10, 10, 10],
    aspectRatio: 1,
    onChange: update,
    onSelect: update,
    bgFade: 'true'
}, function () {
    jCropApi = this;
});

jCropApi.animateTo([startX, startY, boxWH, boxWH]);

Thanks for everyone’s help

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T13:25:05+00:00Added an answer on May 30, 2026 at 1:25 pm

    In your else clause you’re not using myJcrop = image.Jcrop({, you’re only writing myJcrop({. In other words, you’re only creating an object in the first clause.

    You don’t even need to declare objects in each clause, why don’t you just adjust the variables:

    var myJcrop;
    
    if (cropperInit == true) {
        getjCropSize();
        var setSelectArray = [10, 10, 50, 50];
    } else {
        alert("cropperInit = false");
        // Make sure startX, startY, etc. are set
        var setSelectArray = [startX, startY, boxWH, boxWH],
    }
    myJcrop = image.Jcrop({
       setSelect: setSelectArray,
       aspectRatio: 1,
       onChange: update,
       onSelect: update,
       bgFade: 'true'
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently trying to access a REST API for the first time using visual
I need to be able to gain access to objects after my activity has
What is the purist or correct way to access an object's properties from within
How can I access Class object for Generics? Currently, I am doing it this
I'm trying to access the Facebook API Admin.getMetrics method via jQuery. I'm correctly composing
Once i have loaded my model and filtered it if i need to, how
I'm working with existing code that has an object store in the form of
In the application I'm working on porting to the web, we currently dynamically access
I'm currently trying to access Active Directory via the dbms_ldap API in Pl/Sql (Oracle).
I've always wondered how you can access the correct state of the current http

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.