语言

Menu
Sites
Language
web app section changer, getActiveSectionIndex does't work

(function()
{
 var page = document.getElementById("hasSectionchangerPage"),
 element = document.getElementById("sectionchanger"),
 sectionChanger, idx=1;
    
 page.addEventListener("pageshow", function() {
  /* Create the SectionChanger object */
  sectionChanger = tau.widget.SectionChanger(element, {
   circular: true,
   orientation: "horizontal",
   useBouncingEffect: true
  });
       
 });

 page.addEventListener("pagehide", function() {
  /* Release the object */
  sectionChanger.destroy();
 });
    
 var index = getActiveSectionIndex();
 console.log("index : " + index);

    
})();

 

app.js (116) :ReferenceError: Can't find variable: getActiveSectionIndex

 

编辑者为: 준수 김 25 5月, 2017

响应

8 回复
Marco Buettner
var index = getActiveSectionIndex();

WTF?! Did you know something about programming in JavaScript or other languages? getActiveSectionIndex() is a method of SectionChanger so put the fuckin reference in front of the method. Read just the fuckin API Reference and you will find in some seconds your mistake. 

https://developer.tizen.org/development/api-references/web-application?redirect=https://developer.tizen.org/dev-guide/3.0.0/org.tizen.web.apireference/html/ui_fw_api/Mobile_UIComponents/mobile_SectionChanger.htm#method-getActiveSectionIndex

준수 김

sorry unfriendly man  i'm beginner

Armaan-Ul- Islam

Just this code will do,

var index = sectionChanger.getActiveSectionIndex();
console.log("index : " + index);
준수 김

this code doesn't work too..

Marco Buettner

It will if you know something about scopes in JavaScript ;)

But are you look some retarded, this code will work if not... you are have to do some basically tutorials about JavaScript...

 

app.js

var element = document.getElementById("sectionchanger"),
	page = document.getElementById("hasSectionchangerPage"),
	sectionChanger,
	activeSectionIndex;

page.addEventListener("pageshow", function() {
	sectionChanger = tau.widget.SectionChanger(element, {
		circular: true,
		orientation: "horizontal",
		useBouncingEffect: true
	});

	activeSectionIndex = sectionChanger.getActiveSectionIndex();
	console.log(activeSectionIndex);
});

page.addEventListener("pagehide", function() {
	sectionChanger.destroy();
});

index.html

<div id="hasSectionchangerPage" class="ui-page">
	<header class="ui-header">
		<h2 class="ui-title">SectionChanger</h2>
	</header>

	<div class="ui-section-changer" id="sectionchanger">
		<div>
			<section>
				<h3>LEFT1 PAGE</h3>
			</section>

			<section class="ui-section-active">
				<h3>MAIN PAGE</h3>
			</section>

			<section>
				<h3>RIGHT1 PAGE</h3>
			</section>
		</div>
	</div>
</div>

 

준수 김

already i try this, but doesn't work

ReferenceError unhappen, but  log do not printed

Marco Buettner
you can change console.log to alert ;)
준수 김

that's not real solution

I solve this problem

    element.addEventListener("sectionchange", function() 
    {
        sectionChanger = tau.widget.SectionChanger(element);
        var index = sectionChanger.getActiveSectionIndex();
        console.log("index : " + index);
    });