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

  • Home
  • SEARCH
  • 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 8715851
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:56:42+00:00 2026-06-13T05:56:42+00:00

In settings of jqPuzzle i can pass the success function that will be called

  • 0

In settings of jqPuzzle i can pass the success function that will be called when person completes the puzzle. The problem is that i have several puzzles on my page and i would like to make a action with the puzzle that is currently completed but result has only seconds and number of moves. How to get the puzzle that was currently completed?

Here is the demo of what i talk about: http://polishwords.com.pl/dev/puzzle/exa.php

The important part is:

function initializePuzzle()
{
    var settings = {
      cols: 3,
      rows: 3,
      success: { 
          callback: function(results) {  
              //results.moves and results.seconds, but how to get the puzzle that was completed?
              alert(results.moves);
              var puzzleThatWasCompleted = ???;
          } 
      } 
    };

    $('.puzzle').jqPuzzle(settings);  //Changing all images of class puzzle to puzzles
}
  • 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-13T05:56:43+00:00Added an answer on June 13, 2026 at 5:56 am

    If you can pass a success function to any one instance puzzle, then you could pass a different “version” of the function to each instance of the puzzle, and for each version to contain identifier(s) which indicate which particular instance it relates to. That’s the dumb approach.

    The smart approach is to define the success callback inside another function, thereby forming a “closure”. This allows the success callback to be identical in each case but to have access to outer variable(s) identifying the instance.

    Your code is already ripe for this approach and very little needs to change.

    In the following modification of your code, a string or number is passed to initializePuzzle(). The formal variable puzzleID is trapped in a closure, and remains availble to the success callback when it fires.

    You also need to specify each puzzle’s container more precisely. The class selector .puzzle will potentially address multiple elements, but worse it will be the same every time initializePuzzle() is called. Therefore you need to pass a unique id to the function each time it is called.

    function initializePuzzle(puzzleID, containerSelector) {
        var settings = {
            cols: 3,
            rows: 3,
            success: {
                callback: function(results) {
                    alert('PUZZLE ' + puzzleID + ': ' + results.moves);
                }
            }
        };
        $(containerSelector).jqPuzzle(settings); 
    }
    

    Now all you need to do is to call initializePuzzle() something like this :

    initializePuzzle('A', '#puzzle1');
    initializePuzzle('B', '#puzzle2');
    initializePuzzle('C', '#puzzle3');
    

    DEMO

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

Sidebar

Related Questions

I have setup a settings bundle and can successfully pull data from that. I
Libspotify stores settings in a file called settings. Now, it seems that it discards
I have settings that I store in my database. There is an entity class
I have a settings file in my Winforms application called Settings.settings with a partial
I have a profile settings page where users can change their password and they
I have some global settings in my application that is going to be handled
In settings.py I have setup a way to log my messages like this: logging.basicConfig(
are there different sensitivities/settings to whitespace in ruby? i have a RoR project, where
What settings should be changed while setting up php WAMP so that undefined variable
I have some settings stored in web.config like this: <add key=Answers value=radiobutton1,radiobutton2,radiobutton3/> Radiobutton1, radiobutton2

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.