I'm very new to JavaScript and Tizen Web development. So I'm trying to implement rotary selector. And after choosing one element I want to switch to it's specific page. Now I can select the element but can't switch to another page.
index.html
<div class="ui-page" data-enable-page-scroll="false" id="selector-page">
<div class="ui-selector" id="selector">
<div class="ui-item human-icon" data-title="Human"></div>
<div class="ui-item show-icon" data-title="Show"></div>
<div class="ui-item human-icon" data-title="Human"></div>
<div class="ui-item delete-icon" data-title="Delete"></div>
<script src="selector.js"></script>
</div>
</div>
selector.js
/* global tau */
(function () {
var page = document.getElementById("selector-page"),
selector = document.getElementById("selector"),
selectorComponent,
clickBound;
function onClick(event) {
var target = event.target;
if (target.classList.contains("ui-selector-indicator")) {
return;
}
}
page.addEventListener("pagebeforeshow", function () {
clickBound = onClick.bind(null);
selectorComponent = tau.widget.Selector(selector);
selector.addEventListener("click", clickBound, false);
});
page.addEventListener("pagebeforehide", function () {
selector.removeEventListener("click", clickBound, false);
selectorComponent.destroy();
});
}());
UPDATED
I've added this code and it works for me, but I'm not sure that it is the right way to do this.
index.html
<div class="ui-page" data-enable-page-scroll="false" id="selector-page">
<div class="ui-selector" id="selector">
<div class="ui-item human-icon" data-title="Human">
<a href="page2.html" class="next-page"></a>
</div>
...
selector.js
function onClick(event) {
var target = event.target;
if (target.classList.contains("ui-selector-indicator")) {
tau.changePage(document.getElementsByClassName(target.className)[0].getElementsByClassName("next-page")[0].getAttribute("href"));
return;
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…