Page 1 of 1

Adding the Carousel Frames from Javascript Code

Posted: Fri Mar 27, 2015 1:40 pm
by Mark Wong

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...


Adding the Carousel Frames from Javascript Code

Posted: Fri Mar 27, 2015 2:03 pm
by Bruce Stuart

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


Adding the Carousel Frames from Javascript Code

Posted: Fri Mar 27, 2015 2:40 pm
by Mark Wong

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


Adding the Carousel Frames from Javascript Code

Posted: Fri Mar 27, 2015 6:55 pm
by Mark Wong

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


Adding the Carousel Frames from Javascript Code

Posted: Mon Mar 30, 2015 1:01 am
by Yurii Orishchuk

Hi Mark,

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

Regards.


Adding the Carousel Frames from Javascript Code

Posted: Sat Apr 04, 2015 4:28 am
by Mark Wong

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!

Adding the Carousel Frames from Javascript Code

Posted: Sat Apr 04, 2015 6:03 am
by Mark Wong

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


Adding the Carousel Frames from Javascript Code

Posted: Sat Apr 04, 2015 10:15 am
by Alena Prykhodko

Hello Mark,

Could you please clarify, do you need further assistance?


Adding the Carousel Frames from Javascript Code

Posted: Sat Apr 04, 2015 10:55 am
by Mark Wong

No, thank you