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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T08:09:02+00:00 2026-05-31T08:09:02+00:00

I have this plugin issue for ages but can’t get it right. Here is

  • 0

I have this plugin issue for ages but can’t get it right.

Here is the test page. When you click on the page button, it should alert page twice, but it alert photo at the second time.

It does that because I re-use that plugin for another button called ‘photo’. I think the second button overwrite the first button in someway which I don’t quite understand why it does.

$(document).ready(function(){

    $('.get-page').get_overlay({
        targetObject:         '.page'
    });

    $('.get-photo').get_overlay({
        targetObject:         '.photo'
    });

});

Then this means that this plugin cannot be reused at all then what is the point having a plugin in the first place?

Any idea where I have done wrong in this plugin? How can I fix it?

(function($){

    $.fn.get_overlay = function(options) {

             var defaults = {
                targetObject:            ''
            }

            var options =  $.extend(defaults, options);
            var o = options;

            var $cm = this.click(function() {

                alert(o.targetObject);

                $.fn.get_overlay.centralise();

                return false;



            });

            if(!$.fn.get_overlay.centralise) $.fn.get_overlay.centralise = {};

            $.fn.get_overlay.centralise = function() {

                alert(o.targetObject);

            }

    }      
})(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-05-31T08:09:03+00:00Added an answer on May 31, 2026 at 8:09 am

    @lauthiamkok, I think you need to revise the plugin authoring guide at jquery docs. It’s probably not a good idea to do this $.fn.get_overlay.centralise inside you plugin. If you want to have access to centralise() from the public scope you should make it a method. Then, as the authoring guide advises, it’s recommended to return the jquery object to allow chaining for your plugin.
    Check working example at http://jsfiddle.net/elclanrs/FrMSY/1/

    $.fn.get_overlay = function(options) {
    
        var o = $.extend({
            targetObject: ''
        }, options);
        var $this = this;
    
        $this.centralise = function() {
            alert(o.targetObject);
        };
    
        return this.each(function() {
            $(this).click(function() {
                alert(o.targetObject);
                $this.centralise();
                return false;
            });
        });
    
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Anyone have experience with this plugin? I have it installed but I have no
I have tryed to run this code in my console: script/plugin install git://github.com/apotonick/cells.git ...but
i have been pretty pleased so far with this plugin, but am having a
We are using this excellent plugin for some small sparkline charts. Issue I have
I have this function from a plugin (from a previous post) // This method
I have a plugin that is loaded by this application.. This plugin calls some
I install plugin open_id_authentication and have this error: /usr/lib/ruby/gems/1.9.1/gems/activesupport-3.0.0.beta/lib/active_support/dependencies.rb:167:in `require': no such file to
Again I have a question regarding this plugin: http://t.wits.sg/2008/06/20/jquery-progress-bar-11/ What I want to achieve
how do i solve this: I have usercredential informtion in my main RCP plugin.
I have a following problems with eclipse, when I installed ClearCase plugin from this

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.