I have a problem with the behavior of Firefox 4 in regards to parameters passed to the function that is getting called upon a click event.
Take a look at this example:
<html>
<head>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/mootools/1.11/mootools.js"></script>
</head>
<body>
<span id="e">Klick mich!</span>
<script type="text/javascript">
$("e").addEvent("click", function(a, b, c){
alert(this);
alert(a);
alert(b);
alert(c);
console.log(this);
console.log(a);
console.log(b);
console.log(c);
}.bind(1, [2, 3]));
</script>
</body>
</html>
If you open this with Firefox 4 the result is:
- 1
- 2,3
- object MouseEvent
- undefined
In any other browser the result is:
- 1
- 2
- 3
- undefined
As you can see only Firefox 4 passes an MouseEvent to the function. This behavior breaks a lot of my code.
Do you know any solution? Thanks for help.
EDIT1: Chrome behaves like FF4
the problem is – this is mootools 1.11 – UNSUPPORTED AND OLD
in mootools 1.11, it was accepted to use ( http://docs111.mootools.net/Native/Function.js#Function.bind ):
hence, doing .bind(1, [args])
wascorrect. However, recently the nativeFunction.bindimplementation changed in browsers that implement it – https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function/bindit means, to make it work you need
.bind(1,2,3,4);where 1 is bound scope and 2,3,4 are arguments.you SHOULD upgrade, running mootools 1.11 on browsers that came 4 years after it got written will yield unpredictable results. always. for example, 1.11 won’t detect gecko/ff anymore due to deprecated func used to test for it.
what next, check for netscape4? 🙂