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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T20:03:37+00:00 2026-06-16T20:03:37+00:00

I have built a jQuery Plugin, but now I need to use one function

  • 0

I have built a jQuery Plugin, but now I need to use one function from the Plugin outside of the Plugin.

The Plugin

(function ($) {
    jQuery.fn.vierGewinnt = function () {
 var VierGewinnt = function (config) {
            this.view = config.view;    
            this.dx;
            this.turn = 1;
        }
VierGewinnt.prototype.setToken = function (column) {
            for (var i = this.rows; i > 0; i--) {
                if (this.gamearray[column][i] == 0) {
                    this.gamearray[column][i] = "red";    
                    this.turn++;
                    this.findWinner(column, i);
                    break;
                }
            }

        }})(jQuery);

main.js I have tried:

$.setToken()
$.fn.vierGewinnt.setToken()
$.fn.vierGewinnt.VierGewinnt.setToken()

Maybe someone has a clue! Thx in advance!

  • 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-16T20:03:38+00:00Added an answer on June 16, 2026 at 8:03 pm

    The way you have done it, you can’t call it from outside.

    There are a few patterns how you can make js/jquery widgets.

    You are trying to combine the “normal” prototype with jQuery.

    As I see you have two options.

    1. Wrap you jQuery method to return the instance of the constructor. You can call prototype methods on it. Something like:

      $.fn.vierGewinnt = function(config){ 
          return new VierGewinnt (config); 
      };
      

      Then you can instance the plugin and call the method

      var plugin = $('#someSelector').vierGewinnt();
      plugin.setToken(column);
      

      In this case almost all your code can go outside the (function ($) block. You are just using jQuery as a wrapper, everything else is just ordinary javascript. As far as I can see your plugin is not called on any DOM element. It that case I don’t see a lot sense in a jQuery plugin… it is pure javascript. If that is the case, just loose all the jQuery stuff from your example, and it will work.

    2. Use a different plugin pattern. Personally I like the jQueryUI widget factory approach, but you will have to include jQueryUI for it. Docs

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

Sidebar

Related Questions

Good afternoon people's I have built a jquery plugin that I use on my
So I have built a custom dialog JQuery Plugin, but am having issues with
I have built this accordion using the jquery ui accordion plugin, I sort of
I am using jQuery cycle in combination with a mousewheel plugin. I have built
I have a web application built with jQuery Mobile and PHP (CodeIgniter framework). Now
I have built a simple menu in jQuery http://vanquish.websitewelcome.com/~toberua/ Here is a sample of
I have built a an app in PhoneGap/Cordova and used the JQuery library for
I have a slideshow built in flash that I want to mimic in jQuery.
I have a simple jQuery script that I'm trying to build upon but I
I have a flat CSV file which I need read from to end up

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.