Page 1 of 2

Using Carousel with javascript.

Posted: Mon Sep 23, 2013 1:17 am
by bahar.wadia

Has anyone successfully implement the carousel component and manipulated the component with javascript ?

I have tried to get this to work for over a month and have had no luck.

I have been pointed to the same documentation many times and I'll keep my comments to myself :(

Here is all I am trying to do:

1) Add images to the carousel via javascript

2) Delete images from the carousel via javascript

A simple example will go a long ways. PLEASE HELP !!


Using Carousel with javascript.

Posted: Mon Sep 23, 2013 1:21 am
by Alena Prykhodko

Hello!

Please post JS code you tried..


Using Carousel with javascript.

Posted: Mon Sep 23, 2013 1:26 am
by bahar.wadia

Appery('mobilecarousel_7').add('image','', value);

Appery('mobilecarousel_7').refresh();

Where value is a dataURL that I receive from the REST database


Using Carousel with javascript.

Posted: Mon Sep 23, 2013 9:25 pm
by Kateryna Grynko

Hi Bahar,

You can't create new Carousel items yet. You can create GenericService and there generate the required items, and then map them to the Carousel.

Here is a workaround for adding new frames in runtime. The following code adds one frame with an image:
codevar new_frame = $("<div><&#47;div");
new_frame&#46;attr({
"id": "tester", &#47;&#47; required!
"data-type": "image", &#47;&#47; required!
"data-title": "tester",
"data-image-url": "http:&#47;&#47;dummyimage&#46;com&#47;600x400&#47;91b8c9&#47;15f1e6"
});

Appery( "mobilecarousel_5" )&#46;carouselRoot&#46;find( "&#46;ui-carousel-items" )&#46;append( new_frame );
Appery( "mobilecarousel_5" )&#46;carouselRoot&#46;carousel( "refresh" );/code
Unfortunately, the data (frame settings) should be added via attributes, not with code$&#46;data()/code

The same is for HTML frame. Add the needed content in "new_frame".

Here is the deletion:codeAppery( "mobilecarousel_5" )&#46;carouselRoot&#46;carousel( "remove", index );
&#47;&#47; or
Appery( "mobilecarousel_5" )&#46;carouselRoot&#46;carousel( "remove", 0, $frame_dom_element );/code


Using Carousel with javascript.

Posted: Mon Sep 23, 2013 9:35 pm
by bahar.wadia

Ok. I will try this.


Using Carousel with javascript.

Posted: Sun Oct 06, 2013 9:46 pm
by bahar.wadia

Awesome!

That worked out quite nicely !


Using Carousel with javascript.

Posted: Sun Oct 06, 2013 10:16 pm
by bahar.wadia

I have a followup question.

How can I find a frame with a specific Title ?

I want to find the frame with a specific Title and delete.


Using Carousel with javascript.

Posted: Mon Oct 07, 2013 9:23 am
by Maryna Brodina

Hello! Try this code:
preAppery( "mobilecarouselName" )&#46;carouselRoot&#46;carousel( "remove", 0, $("[dsid=mobilecarouselName]")&#46;find('div[data-title="Title text"]')&#46;eq(0));/pre


Using Carousel with javascript.

Posted: Sat Oct 12, 2013 7:36 pm
by bahar.wadia

That works well!


Using Carousel with javascript.

Posted: Sat Oct 12, 2013 7:42 pm
by bahar.wadia

How could I iterate through the Carousel and retrieve the images from each frame.

Thanks