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.
Asked
Active
Viewed 325 times
1
-
What do you mean by permanently remove? Scripts are local to a page, right? So if the function you want to remove in moo is called f, then put in a script tag with the statement `moo.f = undefined`. Any calls of the form `moo.f()` would break on that particular page, of course, but I think the "rest of the site" would be okay. – Ray Toal Jul 10 '11 at 03:38
-
Which function and how is it called? Is it a *global* function or is it in the "moo namespace"? – Jul 09 '11 at 22:32
-
What is the specific conflict because it depends upon what moo functionality it is that is conflicting? Different types of things would take different methods to remove. I don't think there is a general purpose answer without knowing the exact item. For example, you'd have to do something different to replace an override the moo sets vs. just get rid of some moo function. – jfriend00 Jul 09 '11 at 22:41
-
The problem child is the create method in the following code in moo tools 1.2.x (and upgrading isn't an option) I need to un define create as this conflicts with some things in FB.ui in facebook's javascript API. You can find the exact function definitions in http://mootools.net/download/get/mootools-1.2.5-core-nc.js at line 566. That's what I need to undefine. Function.implement({ create: function(options){ – Jacob Bolton Jul 10 '11 at 18:22
3 Answers
4
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

Saxoier
- 1,287
- 1
- 8
- 8
2
Maybe overriding the function would be the solution?
Overriding a JavaScript function while referencing the original

Community
- 1
- 1

ElonU Webdev
- 2,451
- 14
- 15
-
In many cases this would work. For my specific instance I need it to be gone as removing the function altogether fixes my conflict. – Jacob Bolton Jul 10 '11 at 03:29
0
MooTools version 1.4.3 solves this issue - you may download it from Download MooTools 1.4.3

Zorayr
- 23,770
- 8
- 136
- 129