How can I load a Gallery widget inside the content of a Tab widget?
I've tried putting the:
<div data-bind="dxGallery: { dataSource: galleryData }"></div>
Inside the content
parameter of the tab widget:
tabs = [
{ text: L["ABOUT_ME"], icon: "user", content: '<div data-bind="dxGallery: { dataSource: galleryData }"></div>' }
But the widget is not displayed in this way. How can I do?
Please follow recommendations from here.
Use the if binding in your scenario. Your code should be as follows:
<div id="tabs" data-bind="dxTabs: { items: tabs, selectedIndex: selectedTab }"></div>
<div id="tabContent" style="height:300px;" >
<!-- ko if: !selectedTab() -->
<div>Tab1</div>
<!-- /ko -->
<!-- ko if: selectedTab() == 1 -->
<div data-bind="dxGallery: { dataSource: galleryData }"></div>
<!-- /ko -->
<!-- ko if: selectedTab() == 2 -->
<div>Tab3</div>
<!-- /ko -->
var viewModel = {
galleryData: [
"images/person1.png",
"images/person2.png",
"images/person3.png"
],
tabs: [
{ text: "user", icon: "user" },
{ text: "comment", icon: "comment" },
{ text: "find", icon: "find" },
],
selectedTab: ko.observable(0)
};