Reputation: 4711
Is there a way to get indexOf on this array?
var myArray = new Array(
{title: "Test1", id: "Header1", html: "Header1", style: "background-color: red; color: white;"});
Upvotes: 1
Views: 211
Reputation: 4711
This is what I did to make it work -- but it's not pretty:
//Check to see if we are going to a card that should be right or left.
var rightOrLeft = "left";
var destinationIndex = 0;
for(var i=0; i < dynamicPreezeArray.length; i++){
if (dynamicPreezeArray[i].id == this.text) {
destinationIndex = i;
};
}
if (destinationIndex < currentCarouselIndex) {
rightOrLeft = "right";
}
preezer.setActiveItem(this.text,{type:'slide',direction: rightOrLeft});
currentCarouselIndex = preezer.getActiveIndex();
This was all just to make my Sencha carousel look right when clicking buttons, but now I realize that if someone slides it manually that it wont set the currentCarouselIndex... bleh, this is a lot of work just to make it look a little better.
Upvotes: 0
Reputation: 47776
If you want to be able to do a search for that object, if you have the same reference, sure.
var o = {"foo": "bar"};
var a = [o];
alert(a.indexOf(o));
But this won't work:
alert(a.indexOf({"foo": "bar"}));
Upvotes: 2