Problem is: context variable _curIndex is set when there is first call of switchTo (at point a):
function ShowSwitcherObject( id, switchIds )
{
this._id = id;
this._isInited = false;
this.isInited = function()
{
return this._isInited;
};
this._visible = false;
this.show = function()
{
if( this._visible == false )
{
$( '#' + this._id ).show();
this._visible = true;
this._isInited = true;
}
};
this._showSwitch = function()
{
$( '#' + this._switchIds[ this._curIndex ] ).show();
};
this._hideSwitch = function()
{
$( '#' + this._switchIds[ this._curIndex ] ).hide();
};
this.switchTo = function( index )
{
if( index != this._curIndex ) // point a
{
if( this._curIndex != null )
{
this._hideSwitch();
}
this._curIndex = index; // point b
this._showSwitch();
}
};
this._switchIds = switchIds;
return this;
}
It’s interesting that if we comment point b the variable is null at point a.
There are no external sets of _curIndex. It could be only set by switchTo. Is it firefox bug or something else?
From your code it seems
this._curIndexwould beundefinedat point a.If you need
this._curIndexto be null, you must set it to null yourself, since the Javascript interpreter doesn’t resolve uninitialized variables tonull, but ratherundefined.Try this instead: