Orson
Orson

Reputation: 15451

How can i call a JQuery function outside of a JQuery class?

I have a class:

var BrandDrug = Class.extend({
    fun1: function() {
       $.MyFunc(); //This does not work.
    }
});


//Outside function
$.MyFunc = (function() {
   //Code
});

How can i call the $.MyFunc from the BrandDrug Class?

Upvotes: 2

Views: 417

Answers (1)

Jan Hančič
Jan Hančič

Reputation: 53929

You have to define the "$.MyFunc" before the "BrandDrug" class and it will work.

edit: also note that you are not extending jQuery properly. See this tutorial (for example) on how to build proper jQuery plugins.

Upvotes: 1

Related Questions