Jacob Bolton
Jacob Bolton

Reputation: 83

Is it possible to undefine a javascript method?

Specifically I am needing to unset a function in mootools for one page that is conflicting with a FB.ui. But I don't want to do anything drastic such as permanently remove that function as it would break the rest of the site.

Upvotes: 1

Views: 346

Answers (3)

Zorayr
Zorayr

Reputation: 24962

MooTools version 1.4.3 solves this issue - you may download it from Download MooTools 1.4.3

Upvotes: 0

Saxoier
Saxoier

Reputation: 1287

var moo = new function()
{
    this.fn = function()
    {
        return 1;
    };
};

moo.fn(); // 1
var _moofn = moo.fn; // 'cache pointer'
moo.fn = function(){};
moo.fn(); // nothing
moo.fn = _moofn;
moo.fn(); // 1

Upvotes: 4

ElonU Webdev
ElonU Webdev

Reputation: 2459

Maybe overriding the function would be the solution?

Overriding a JavaScript function while referencing the original

Upvotes: 2

Related Questions