I am trying to create a property of an object that I can access from another function. I've been trying to figure out dot / bracket notation but I'm not getting it. Would one of you please help me figure how to make the objects state readable from another function.
function twoPhaseSwitch(object,state)
{
var obj = $(object);
stage.getSymbol(obj).stop(state);
obj.click(function(e)
{
if(obj.state == 'off')
{
stage.getSymbol(obj).stop('on');
obj.state = 'on';
}else{
stage.getSymbol(obj).stop('off');
obj.state = 'off';
};
});
};
function conditionsArray(obj)
{
for (var i=obj.length;i--;)
{
alert(obj[i].state);
};
};
I'm not sure if this is the correct answer but it works. I ended up using jQuery's .data() call.
//in switch function
obj.data('state',state);
//in conditionArray
alert($(obj[i]).data('state'));