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 7888591
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:52:15+00:00 2026-06-03T05:52:15+00:00

There is the part of my code which works perfectly var image_mini = $(‘#map_mini’);

  • 0

There is the part of my code which works perfectly

var image_mini = $('#map_mini');
var image_full = $('#map_full');

function state_change(data) { 
   // This is just part of code which show idea
   image_mini.mapster(data.state);
}

// This is full block of code, works correct
$("#map_full").mapster(
     $.extend({}, options, {
         onStateChange: state_change
     })
);

Now I need to enhance function state_change so, that it fill recive second agrument with image variable, which will be use insted of the directly writed image_mini.

Something like this (the code below is WRONG), but with CORRECT syntax code:

function state_change(data, working_image) {  
  working_image.mapster(...);
}

$("#map_full").mapster(
     $.extend({}, options, {
         onStateChange: state_change, image_mini
     })
);

I feel me lamer, but I haven’t found example of correct sintax for passing two variables in such onStateChange… I tried some ideas, but it didn’t work correctly.
Please help!

==============================
Added later:

Looks like my idea wasn’t understood correctly, so I write more of code:

var image_mini = $('#map_mini');
var image_full = $('#map_full');

function state_change(data, working_image) {  
  working_image.mapster(data.state);
}

$("#map_full").mapster(
     $.extend({}, options, {
         onStateChange: state_change, image_mini
     })
);
$("#map_mini").mapster(
     $.extend({}, options, {
         onStateChange: state_change, image_full
     })
);

This is idea of what I want: both images must be crosslinked, so changes on one will be showed on both of them.

onStateChange: state_change, image_full

This is WRONG, I ask about correct syntax for the task.

  • 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-06-03T05:52:16+00:00Added an answer on June 3, 2026 at 5:52 am

    It might not be as pretty, but you can do this using:

    $.extend({}, options, {
        onStateChange : function (e) {
            state_change(e, image_mini);
        }
    })
    

    EDIT

    To explain, your first version of code reads like this:

    function state_change(data) {
        // ...
    }
    // ...
    $.extend({}, options, {
        onStateChange : state_change
    })
    

    What happens here is that whenever onStateChange fires, it calls the state_change function. If this follows general jQuery parlance, then that function gets passed the jQuery event object as the function’s first parameter. In this case, that event object would resolve as the data argument in your state_change function declaration.

    My code above, follows the same logic:

    onStateChange : function (e) {
    }
    

    So when onStateChange fires, it’ll call that anonymous function, and pass in the event object as the first argument. This will resolve as e inside the handler function. Therefore:

    onStateChange : function (e) {
        state_change(e, image_mini);
    }
    

    … performs mostly the same thing with respect to the event object. When the onStateChange event fires, the handler gets the event object as e, which it will then pass to the call to state_change. That’ll resolve to data inside state_change as a result, and will not change how you use the original function much.

    This way, however, we’re free to pass in additional arguments into the call to state_change, like throwing in image_mini or whatever.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any gem which works on Rails 3 that can show which part
Are there any open source projects or part of codes using which its possible
My code counts spaces in string temp , which works fine. Later in the
Prerequisites: Android 2.2 emulator. I have a perfectly working Java code which is compiled
I have the following code which works as expected: #include <iostream> using namespace std;
Here is my simple code, which works fine if called from php or any
Reading Java Concurrency In Practice, there's this part in section 3.5: public Holder holder;
Is there any way to get just a part from MySql cell and ignore
Is there a way to update only Hour part in a DateTime field?? If
is there any best practice way to replace a part of the default template.

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.