Take the 2-minute tour ×

I have a plugin that looks like this:

(function($) {
    $.fn.plugin_name = function(options) {

        var $this = $(this);

        var defaults = {
            // some defaults


        var work = {
            action_1: function() {
                // do something
            action_2: function(output) {
                alert('hello world');

        that.submit(function(e) {

        return $this;

It's being used like any traditional jquery plugin, by being attached to a page element like so:

    // overide options

My question is, how can I execute the work.action_2() function that's deeply nested inside the plugin? I would like to call it manually from the javascript console in firebug.

share|improve this question
You recommend that you start by following the plugin authoring guidelines (docs.jquery.com/Plugins/Authoring) –  jgauffin Mar 20 '12 at 19:45
By the way, you have no that declared in the code, did you mean this? –  gdoron Mar 20 '12 at 19:47
add comment

2 Answers

up vote 2 down vote accepted


You can't, it's outside of your scope!

you can't reach private function variables, just like you can't reach my functions...

share|improve this answer
I figured this was the issue, only reason why I needed this was because I am making a call to one of the google apis and they accept a callback function as one of the parameters. Google only recognizes this function if it's in the global sphere. If I put that function outside the plugin then I can't use the plugin's options :( –  TK123 Mar 20 '12 at 19:58
@JakeRow123. You can define it the the global scope, and call it with the options values. Simple isn't it? –  gdoron Mar 20 '12 at 20:00
add comment

Create it in a separate utility function if its needed independently, better if its in your own global object. So you can call it like so: $.myGlobalObj.action_2()

share|improve this answer
add comment

Your Answer


