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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:26:42+00:00 2026-05-23T08:26:42+00:00

One of our old developers has built a jQuery plugin like so: jQuery.fn.limelight =

  • 0

One of our old developers has built a jQuery plugin like so:

jQuery.fn.limelight = function(options) {  

/*Skipped code here*/

jQuery(".spotlight-btn.back a").click( function (e) {

            if(lastSelectedCastIndex - 1 >= 0) {
                removeFromSpotlight();
                lastSelectedCastIndex--;
                e.preventDefault();
                $.address.value(lastSelectedCastIndex);
                ca$t.scroll(jQuery.jcarousel.intval(lastSelectedCastIndex), true);
                switchTo(lastSelectedCastIndex);
            }
            return false;
        });

function switchTo(i)
{
    ca$t.scroll(jQuery.jcarousel.intval(i), true);
    $.address.title($("#title_text").text());
    putInSpotlight();
}
};

I’ve not done any jQuery plugin programming, but would like to expose the switchTo function so it can be called anywhere. How would I be able to do this?

  • 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-23T08:26:42+00:00Added an answer on May 23, 2026 at 8:26 am

    This is probably overkill for your purposes, but it doesn’t seem like your developer really understood or grasped the purpose of jQuery plugins.

    You want a plugin to be somewhat generic where it can accept a selector and apply events, styles, dynamic html, whatever to the item(s) found in the selector. It looks like he wrote a “plugin” for a single purpose… maybe just to maintain some sort of organization.

    Most plugins follow a form similar to this:

    ; (function ($) {
        $.fn.limelight  = function (method) {
            var methods = {
                //Initialize the plugin
                init: function (options) {
                    return this.each(function () {
                    //Refactor to conform to plugin style
    //                    $(this).click( function (e) {
    //                        if(lastSelectedCastIndex - 1 >= 0) {
    //                            removeFromSpotlight();
    //                            lastSelectedCastIndex--;
    //                            e.preventDefault();
    //                            $.address.value(lastSelectedCastIndex);
    //                            ca$t.scroll(jQuery.jcarousel.intval(lastSelectedCastIndex), true);
    //                            switchTo(lastSelectedCastIndex);
    //                        }
    //                        return false;
    //                    });
                    });
                },
    
                switchTo: function (i) {
                //Refactor to conform to plugin style
    //                ca$t.scroll(jQuery.jcarousel.intval(i), true);
    //                $.address.title($("#title_text").text());
    //                putInSpotlight();
    
                }
            };
    
            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.limelight');
            }
        };
    })(jQuery);
    
    //Following this pattern you'd be able to call your plugin like this. 
    $(".spotlight-btn.back a").limelight();
    $(".spotlight-btn.back a").limelight("switchTo", 0);
    

    Here’s the official documentation on the subject: http://docs.jquery.com/Plugins/Authoring

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

Sidebar

Related Questions

One of our developers is continually writing code and putting it into version control
I'm now considering using gperf generated hash function to replace our old one, but
In our old system, we used YUI, but the new one is using jQuery.
I've been tasked with updating one of our old programs still in production and
One of our clients is upgrading their servers because the old machines can't handle
Our team is creating a new recruitment workflow system to replace an old one.
Our team is developing a new product on the base of the old one
One of our weblogic 8.1s has suddenly started logging giant amounts of logs and
I'll be embarking on converting one of our old, legacy apps from VB6 to
We have provisioned 3 devices for our iPhone development. 2 developers and one manager

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.