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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T07:26:36+00:00 2026-05-24T07:26:36+00:00

My plugin takes some time doing something. So I want to listen to when

  • 0

My plugin takes some time doing something. So I want to listen to when the plugin is done with its task, from outside, so that I can display something.

I want to have something like this –

 $('li').filterGroup ({

        onInit: function(){
          alert("plugin has started working");
        },

        onComplete: function(){

          alert("plugin has finished");
        }
    })

I tried writing this inside my plugin code –

(function($) {
    // jQuery plugin definition

    $.fn.filterGroup = function(config) 
    {

        var settings = {
                    //some settings defined here
                        };




            var thisDropdown = this; //master  copy

        if(config)
        {
            $.extend(settings, config);
        }

            /*Tried following changes to make events work*/
            /*Tried following changes to make events work*/
            /*Tried following changes to make events work*/
            //I tried the following – assuming I will be able to listen to an onComplete event from outside

        // reference the function from the options passed
            var theFunc = config.onInit;
            var anotherFunc = config.onComplete;
            theFunc.call(); //does not work - gives error "theFunc is not a function"

        this.each(function() 
        {      
                    //here my plugin logic is done
            anotherFunc.call(); //this is also not working - "anotherFunc is not a function"
        });

        // allow jQuery chaining
        return thisDropdown;
    };

But this is not working, I am getting error –

theFunc is not a function

Note – I checked the PLugins authoring docs and specifically the events section http://docs.jquery.com/Plugins/Authoring#Events, but looks like that is for defining public functions which can be called from outside, so not what I am looking for. Where is the original jquery doc for this? I think I just need to follow the docs properly.

Also checked the following questions but not getting –
Bind Event to Custom Plugin Function in jQuery
Custom Event For Custom JQuery Plugin
Handle events in a jQuery plugin

Update

Okay, got my mistake, in my actual code I had theFunc.call() and anotherFunc.call() but in the calling part I had only handled onComplete. So, do I need to explicitly write the onInit() part in my plugin call –

This part –

onInit: function(){
              alert("plugin has started working");
            }

I mean if events are defined inside plugin, what if I don’t want to handle in the outside code?

  • 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-24T07:26:38+00:00Added an answer on May 24, 2026 at 7:26 am

    Strange. It works for me.
    http://jsfiddle.net/LHzjG/

    BTW, you can also invoke the callbacks directly using config.onComplete() and put params if u like. And you can use jQuery.isFunction() to check if it’s a function beforehand.

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

Sidebar

Related Questions

I am doing some sort of cronjob inside a WordPress plugin that does the
I have a function called Colorbox (jQuery plugin) that takes a number of parameters
I'm trying to build a simple jquery plugin that can take selectors as parameters.
My Active Resource connects to some stupid external service that takes a while to
I have written a nice plugin, which incoporates some generated java sources. I can
I have made a wordpress plugin that can fetch an unknown number of Google
Is there any plugin for jQuery that would take an argument for the max
I'm writing a plug-in for a piece of software that takes a big collection
I'm looking for a jQuery plugin or a standalone script that will take a
I have a method as follows (from a class than implements TBB task interface

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.