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

The Archive Base Latest Questions

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

I have a problem in creating a callback function. First, as far as I

  • 0

I have a problem in creating a callback function. First, as far as I can understand, a callback acts like a parametr which triggers when all the action in its “parent” function has finished. For example:

$('p').hide('slow', function() {
    $(this).show('slow');
});

At first <p> is hidden, and only afterwards it shows again.

How can I apply such callback in a random plugin?

For example a plugin looks like this:

 $.fn.myPlugin = function(settings) { 
   return this.each(function() {
    settings = $.extend({ onShow: null }, settings);
    $(this).hide('slow');  /*This action should happen first (First action)*/
    if ( $.isFunction( settings.onShow ) ) 
     settings.onShow.call(this);/*Callback should fire after First action has stopped*/
     }
   });
 };


$(document).ready(function() 
   $('p').myPlugin({
     onShow: function() {
     alert('My callback!');/*Both actions(element hiding and alert ) 
                             fire simultaneously, but I need alert 
                             to fire after element is hidden*/
      }
   });
});
  • 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-15T13:42:31+00:00Added an answer on May 15, 2026 at 1:42 pm

    A callback function is a function, which is passed to another function/method and gets called at some point.

    If we create a function like

    function mightyplugin(foo, callback){
       // big code block here
    
       callback.apply(this, [foo]);
    }
    

    we now have a function, which calls another function. In this example, it parses one parameter through it and calls our callback-function within the scope of this.

    A call would look like

    mightyplugin("Bar!", function(param){
        alert(param);
    });
    

    we pass an anonymous function (more precisly, a reference) to mightyplugin() and we can access our parameter in there, since we call that anonymous function with a scope and an array of parameters (which only holds the original parameter here).

    Those constructs must already be implemented by a plugin, otherwise you need to create your own functionality.

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

Sidebar

Ask A Question

Stats

  • Questions 458k
  • Answers 458k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The first example is typically a way people achieve the… May 15, 2026 at 11:14 pm
  • Editorial Team
    Editorial Team added an answer If you never properly learned C++ (you say you learned… May 15, 2026 at 11:14 pm
  • Editorial Team
    Editorial Team added an answer start IDLE open eggs, open ham set desired breakpoints in… May 15, 2026 at 11:14 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.