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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:11:29+00:00 2026-06-17T19:11:29+00:00

I have created a jQuery plugin which listens to window for blur events. I

  • 0

I have created a jQuery plugin which listens to window for blur events.

I want to create a unique id inside of the plugin itself so I can off the listener when I destroy instances of the plugin. How should I create these uniqueIds?

The example below clearly does not work — incrementId in the destroy method is always removing blur from the last plugin instance.

 (function( $ ) {

    var incrementId = 0;

    var methods = 
    {
        init : function( options ) {
            var that = this;
            incrementId += 1;
            $(window).on( "blur.pleaseKillMe" + incrementId, function( e ) {
                that.css( "color", "red" );
            });
        },

        destroy : function( ) {
            console.log( "and... " + incrementId );
            $(window).off( "blur.pleaseKillMe" + incrementId );
        }
    };

    $.fn.pleaseKillMe = function( method )
    {
        if ( methods[method] ) {
            return methods[ method ].apply( this, Array.prototype.slice.call( arguments, 1 ));
        }
        else if ( typeof method === 'object' || ! method ) {
            return methods.init.apply( this, arguments );
        }
        else {
            $.error( 'Method ' +  method + ' does not exist on jQuery.p5shrinkwrap' );
        }
    };

})( jQuery );
  • 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-17T19:11:30+00:00Added an answer on June 17, 2026 at 7:11 pm
    incrementId += 1;
    this.data('id', incrementId);
    ...
    $(window).off('blur.pleaseKillMe' + this.data('id');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I DO NOT WANT TO CREATE A JQUERY PLUGIN Let's say I have something
NOTE: I have now created a jQuery plugin which is my attempt of a
I have created a jQuery plugin that is used to create html on a
I have created a jquery plugin to expand/collapse ul,li something like a accordion menu
I am using the jQuery Tools Scrollable plugin - http://flowplayer.org/tools/scrollable.html#navigator I have created a
I have created a jQuery animation that can be seen by clicking the Preview
I have created my own jquery plugin. It is setup like so. ;(function ($)
I have a jQuery selector, which has a chained function. Inside the function I
I need some jQuery plugin, tutorial or guidelines to create simple image gallery which
I have created a jQuery elastic plugin. I have the problem that if I

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.