Some javascript problems

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
Post Reply
Pomegranate
Posts: 33
Joined: Sun Jul 16, 2017 11:53 pm
Location: Mongolia, Ulaanbaatar

Some javascript problems

Post by Pomegranate »

Hi everyone, I'm using some javascript to animate some stacked cards and I keep running into a weird problem and I've narrowed it down to this,

Code: Select all

this.element = element;
this.items = this.element.getElementsByClassName('js-stack-cards__item');
Now the above codes get the items by their class name and stores it into "items"

After that, I'm trying to run this function which fails only in AwareIM for some reason.

Code: Select all

var cardStyle = getComputedStyle(element.items[0]);
I know element.items are returning 28 items as an HTMLCollection by doing a console log,

Code: Select all

console.log(element.items);
Now, the funny part is, this all works in a regular html file, but in aware, when I try to find the first item by using [0], it returns as undefined and the whole script fails because of that, I know how I'm getting an undefined value by doing this

Code: Select all

console.log(element.items[0]);
The above [0] is a standard in javascript and is literally working everywhere else except for AwareIM, have anyone experienced this before? And if so, what were your solutions, thanks for your time.

P.S, all of this is in a rendered script inside of a custom list in a form.
Pomegranate
Posts: 33
Joined: Sun Jul 16, 2017 11:53 pm
Location: Mongolia, Ulaanbaatar

Re: Some javascript problems

Post by Pomegranate »

Using this line instead of the previous one returns a null instead of an undefined :S

Code: Select all

console.log(element.items[0]); //Previous
console.log(element.items.item(0)); //Testing a different method
Post Reply