PDA

View Full Version : "Not enough arguments" error caused by Ext.History



holdenmatt
4 Jul 2011, 11:46 AM
addEventListener requires 3 arguments, but a 3rd argument is missing on line 10170 of sencha-touch-debug:


window.addEventListener('hashchange', this.onChange);

This has caused some production errors for us on Mobile Safari (User agent: UserAgent: Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16).


Until this is fixed in Sencha, this override fixes the problem:


/**
* addEventListener requires 3 arguments in some browsers.
*/
Ext.override(Ext.History, {
init: function() {
var me = this;

me.setToken(window.location.hash);

if (Ext.supports.History) {
/*** Add false as 3rd argument ***/
window.addEventListener('hashchange', this.onChange, false);
} else {
setInterval(function() {
var newToken = me.cleanToken(window.location.hash),
oldToken = me.getToken();

if (newToken != oldToken) {
me.onChange();
}
}, 50);
}
},
});