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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T03:39:00+00:00 2026-05-16T03:39:00+00:00

I have a custom plugin, with a constructor like this: (function($){ $.fn.extend({ myplugin: function(options)

  • 0

I have a custom plugin, with a constructor like this:

 (function($){

    $.fn.extend({ 

        myplugin: function(options) {
  [..]

In the plugin, I have a bunch of other functions. Now I attach my plugin to a dom-element:

$('myelement').myplugin()

and after that I want to send a message to the plugin from the wrapping document. Basically, I want to call the internal function with custom parameters from outside. How can I achieve this?

Thanks a lot.

  • 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-16T03:39:01+00:00Added an answer on May 16, 2026 at 3:39 am

    I follow the following pattern while developing jQuery plugins. Its quite helpful:

    (function($)   {
       $.fn.myWidget = function(options)  {
          var defaults = {
             // default options
          };
          // these are our final options
          var opts = $.extend(defaults, options);
    
          // private functions
          var myFunc = function(param) {
          };
    
          // our widget object
          var widget = {
             functionA: function(strMsg)  {
                // do something important or call internal function myFunc
             },
    
    
             functionB: function(idx)   {
                // do something important
             }
          };
          // return the widget object 
          return widget; // THIS WILL HELP YOU CALL FUNCTIONS ON YOUR WIDGET
       };
    })(jQuery);
    
    var w = $("#myDiv").myWidget();
    w.functionA("Hell(o)");
    

    Another way to do it:

    (function($)   {
       $.fn.myWidget = function(options)  {
          var defaults = {
             // default options
          };
          // these are our final options
          var opts = $.extend(defaults, options);
    
          // private functions
          var myFunc = function(param) {
          };
    
          this.functionA = function(strMsg) {
          };
    
          this.functionB = function(param) {
          };
    
          return this;
    
       };
    })(jQuery);
    
    var w = $("#myDiv").myWidget();
    w.functionA("Hell(o)");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a webpage that uses a custom plugin, like this: <embed height=0 width=0
I have custom validation rule: public function customRule($check) { } Inside this rule I
I have a general (custom) jQuery plugin. $.fn.something(). This gets called on some objects
I have an existing jQuery plugin, now I want to extend it. Consider the
This is jQuery code to create a custom plugin. (function( $ ){ var methods
I have a custom jQuery plugin which binds a change event to a form
I am using jquery validation plugin for form validation. I have added a custom
I have custom UITableViewCell . It contains UITextLabel . When I press this cell
i have custom cell with 2 buttons(the function of these buttons is just to
I have a custom WordPress plugin that works fine on my local dev machine,

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.