Data-binding options:
Example:
In this example, the ViewModel is defined specifically for use with the carousel. It has disabled, showPagerand loopproperties that are bound in the View. If any of these values change, then the widgets will automatically respond to them. The widgets also update the ViewModel values as they modify them. The pager is visible and you can loop back through the images from the beginning.
Create a ViewModel:
ViewModel Script |
Copy Code |
---|---|
var viewModel = function () { var self = this; self.disabled = ko.observable(false); self.showPager = ko.observable(true); self.loop = ko.observable(true); }; |
Create View with Bound Controls:
View Markup |
Copy Code |
---|---|
<div data-bind="wijcarousel: {disabled: disabled, showPager: showPager, loop: loop}"> <ul> <li><img src="http://lorempixum.com/750/300/sports/1" alt="Sports 1" /></li> <li><img src="http://lorempixum.com/750/300/sports/2" alt="Sports 2"></li> <li><img src="http://lorempixum.com/750/300/sports/3" alt="Sports 3" /></li> </ul> </div> |