New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot set property 'items' of null #81
Comments
I'm not able to verify this until later, but I'm pretty sure the problem is simply that you're running a pagination function other than init (i.e. updateItems) before having run the init function yourself:
Initialisation is explicit. We can't "automatically" init when you ask to updateItems because we don't know what init options you need. Your code must always init an element as above BEFORE calling any other pagination functions on it. It worked for you with a timeout because your init executed some time after your updateItems, however a timeout should never be needed for this. |
I have tried adding that block before calling updateItems. It seems like it did call init function but not really. I still get the null error the first time activating updateItems (it works the second time). |
Be careful to check that you're actually calling it before updateItems, because when I tested it that's what made the difference: http://jsfiddle.net/sge1830c/2/ An easy way to check is to put console.log()s just before the simplePagination calls to see which one is logged first. I still think that it should be fine as long as you initialise before calling anything else. If you're still having the problem even after a console.log() check then please share more of your code here so we can diagnose and hopefully reproduce the issue. |
Hmm, I followed my own link above from my iPhone and it's always crashing. I'll investigate when I get home. |
I tried your plunker and both init before and init after show the crash message. |
This error gave me a big headache
$('#paginator').pagination('updateItems', numVideos)
. It's supposed to call this function below. Turns out o is null.After much investigation, I realize that the
init
method is called after updateItems, and that's why o, which is the options object, is null. I did a setTimeout on calling$('#paginator').pagination('updateItems', numVideos)
and it seems to prevent the error. I'm not sure why this happens though.The text was updated successfully, but these errors were encountered: