Question

The dojo mobile documentation gives you a way to listen for ant event when a user "Selects" a carousel item: http://dojotoolkit.org/reference-guide/1.8/dojox/mobile/Carousel.html#handling-the-event-when-a-carousel-item-is-selected

But i need to do an action when it's transitioned. is there a way to handle that?

Also is there somewhere i can find all "handleable events" for a widget?

Was it helpful?

Solution 3

After learning more about Dojo, I realized that i didn't approach this correctly.

Create a new module that inherits from carousel. then all you need to do is override the handleViewChanged method (make sure to call this.inherited) then do stuff right in there.

OTHER TIPS

As you can read in the API Doc there are some events implemented. Unfortunately, there none of them seems to match your exact requirements.

Only the onNextBtnClick(e) and onPrevBtnClick(e) seem to go in your direction.

There is also a handleViewChanged(view)-method, but i don't think this refers to the Carousel itsself but to the device its presented on (like going from portrait mode to landscape mode or sth.). But as its not very deeply documented, i can not tell exactly what its for.

You can subscribe to the Dojo topic "/dojox/mobile/viewChanged" which is emitted when any view is transitioned to, and check that the view is a child of your Carousel, like this:

require(["dojo/topic"], function(topic){
    topic.subscribe("/dojox/mobile/viewChanged", function(view){
        if(view.getParent() === myCarousel){
            // a new view inside my carousel has been transitioned to
            ...
        }
    });
});

Alternately, you can actually connect to the handleViewChanged method, since the Carousel subscribes to "/dojox/mobile/viewChanged" internally and calls handleViewChanged.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top