Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSSOR - Cannot read type property 'currentStyle' of undefined

I'm trying to implement the Jssor slider into my page, but I keep coming up with that error in the title.

My content is being dynamically created via Javascript, like so:

var slide = app.createHTML('div', "", {'id':'inventorySlides'}, null);

var div = document.getElementById('invDiv');
div.appendChild(slide);  

and then I procedurally generate cell divs in the same way and append them to slide.

I've defined a function in my main controller as in the example on the basic usage page (http://www.jssor.com/development/basic-usage-no-jquery.html), and after all the content has been generated and appended, I call the function

jssor_slider1_starter('inventorySlides');

But then I get the error message in the console. I've tried logging the inventorySlides div, and it definitely exists in the DOM, so I know it's not that. I tried searching for currentStyles, which turns out is just on IE and Opera, and I'm using Chrome.

So is it something I'm doing wrong? Or is it Jssor that's misbehaving?

like image 359
DanTheMan Avatar asked Aug 08 '14 14:08

DanTheMan


1 Answers

So firstly, I had forgotten to include jssor.core.js and jssor.utils.js, though that did not fully solve my problem.

The Solution was that I needed to create a div with an attribute u="slides", which goes inside the 'inventorySlides' div, and the cells are nested inside this new div

NOTE: I made this answer much later than when it was asked because at the time I did not have enough reputation to be able to answer my own question, and now I no longer have access to the code this question is referencing, so I can't really add much more detail to the answer than what had already been discussed in the comments. I apologize if there's any details you need that this answer does not provide, but I can't help much past this point. Cheers - Dan

like image 66
DanTheMan Avatar answered Nov 16 '22 03:11

DanTheMan