Mark Wong
Posts: 0
Joined: Sat Feb 14, 2015 7:47 am

Adding the Carousel Frames from Javascript Code

I have use a service to count the total of the require objects, and it returns and store in the localStorage item called "total"
When the service success, I do the mapping and run the JS code:
codevar carousel = jQuery('[name="mobilecarousel_24"]');
var total = localStorage.getItem("total");
var require = Math.ceil(total/5);
carousel.carousel("add", require);
Appery( 'mobilecarousel_24' ).refresh();/code
Refresh Exception: cannot call methods on carousel prior to initialization; attempted to call method 'refresh'(Even I didn't put the refresh code);
After I put the refresh code, it appears another error:
carousel refresh
I think there is something wrong in my code or I need the parameters...

Bruce Stuart
Posts: 0
Joined: Fri Oct 24, 2014 4:42 am

Adding the Carousel Frames from Javascript Code

Mark,

It's takes some time for a counsel object to form..

While the carousel object is forming, due to the real time multiprocessing nature of today's platforms, other things are running ... Including your code.

So, the error is telling you that you are trying to do something with the cake in your oven ... Before its done.

Use setInterval or setTimeout to 'wait' for your carousel object to finish baking ... And then try to execute your code.

You could also put this code inside of a try - catch loop and re-execute on error.

If this is Greek to you ... Let me know ... I have a couple of examples I could dig up !

Happy Friday

Bruce

Mark Wong
Posts: 0
Joined: Sat Feb 14, 2015 7:47 am

Adding the Carousel Frames from Javascript Code

I would like an example for me to take a look eventhough its not Greek for me XD

Mark Wong
Posts: 0
Joined: Sat Feb 14, 2015 7:47 am

Adding the Carousel Frames from Javascript Code

When I tried the method that Bruce told me,
it works but the Refresh Exception: cannot call methods on carousel prior to initialization; attempted to call method 'refresh'still occurs.

Also there is an error Uncaught Error: c15r: component not found

When I do the action "Swipeleft" on the list which will execute the service,
it will return the carousel item in one only

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Adding the Carousel Frames from Javascript Code

Hi Mark,

Please give us your app public link and describe steps to reproduce this problem in your app.

Regards.

Mark Wong
Posts: 0
Joined: Sat Feb 14, 2015 7:47 am

Adding the Carousel Frames from Javascript Code

http://appery.io/app/mobile-frame?src...

Reproduce the problem:

  1. Register and Login with the account
  2. Swipe left first on the list, which will call the service to skip 5 items.
    (After 1000 ms, the Carousel item is added one more.)
  3. Swipe right back - The Carousel refresh and the one added before is gone!
Mark Wong
Posts: 0
Joined: Sat Feb 14, 2015 7:47 am

Adding the Carousel Frames from Javascript Code

Sorry guys,
Its my mistake
I thought I put "add"and a number which how many frames I want to add together
Something like ("add", 10)
Which is wrong

Alena Prykhodko
Posts: 0
Joined: Tue Apr 09, 2013 7:36 am

Adding the Carousel Frames from Javascript Code

Hello Mark,

Could you please clarify, do you need further assistance?

Mark Wong
Posts: 0
Joined: Sat Feb 14, 2015 7:47 am

Adding the Carousel Frames from Javascript Code

No, thank you

Return to “Issues”