10-05-2017 09:44
10-05-2017 09:44
I hhink its possible to have different views.
How can i switch to a different View? I cant find this information.
Example:
In index.js there is a Button and on the ClickEvent i would open another View stats.js.
Answered! Go to the Best Answer.
Best Answer10-06-2017 05:26
Fitbit Developers oversee the SDK and API forums. We're here to answer questions about Fitbit developer tools, assist with projects, and make sure your voice is heard by the development team.
10-06-2017 05:26
@SunsetRunner wrote:
Now can i hide my first view, but my second view doesnt work.
You must have something else wrong with your code. Perhaps something else with the same ID?
This works:
https://gist.github.com/orviwan/39a43be3e19a19baf12b577c5e45a074
10-05-2017 12:08
10-05-2017 12:08
I don't know the real answer, but this is using SVG, there's the master SVG tag in the
<svg id="view1" display="none" width="100%" height="100%">
</svg>
<svg id="view2" display="none" width="100%" height="100%">
</svg>
<svg id="view3" display="none" width="100%" height="100%">
</svg>
you can show the view you want by hiding the other views 'display none' and
showing 'display inline' or any viewable setting
var view1 = document.getElementById("view1");
var view2 = document.getElementById("view2");
var view3 = document.getElementById("view3");
view1.attr("display","inline") or whatever code it is to show, you get the point though
Best Answer10-05-2017 12:32
10-05-2017 12:32
I assumed that I would create a new JS file and a new GUI file.
I will try it...
Best Answer10-05-2017 13:26
Fitbit Developers oversee the SDK and API forums. We're here to answer questions about Fitbit developer tools, assist with projects, and make sure your voice is heard by the development team.
10-05-2017 13:26
@SunsetRunner wrote:
I assumed that I would create a new JS file and a new GUI file.
I will try it...
We don't support multiple files at this time, the show/hide approach is correct.
Best Answer10-05-2017 13:31 - edited 10-05-2017 13:32
10-05-2017 13:31 - edited 10-05-2017 13:32
Thanks Jon, so can I do it the way Bastion described it?
Multiple svg tags in one file?
Best Answer10-05-2017 16:50
10-05-2017 16:50
It doesnt work:
index.gui:
<svg id="main" display="inner">
....
index.js:
var view1 = document.getElementById("main");
view1.display = "none";
Error:
[01:47:54]Unhandled TypeError
[01:47:54]Cannot set property 'display' of null
Best Answer10-05-2017 16:53
Fitbit Developers oversee the SDK and API forums. We're here to answer questions about Fitbit developer tools, assist with projects, and make sure your voice is heard by the development team.
10-05-2017 16:53
view1.style.display = "none";
https://dev.fitbit.com/guides/user-interface/javascript/#showing-hiding-an-element
Best Answer10-05-2017 16:59
10-05-2017 16:59
Thx Jon.
Best Answer10-05-2017 17:20
10-05-2017 17:20
Now can i hide my first view, but my second view doesnt work.
<svg id="main" display="inline">
</svg>
<svg id="info" display="none">
</svg>
let view1 = document.getElementById("main");
let view2 = document.getElementById("info");
view1.style.display = "none"; <-- works
view2.style.display = "inline"; <-- null execption
Best Answer10-06-2017 04:51 - edited 10-06-2017 05:19
10-06-2017 04:51 - edited 10-06-2017 05:19
Check out the documentation, you can still have seperate .js files if you
want, just wire them up to what you want to control.
Best Answer10-06-2017 05:23
10-06-2017 05:23
Bah, I don't think you guys need multiple files, declaring pages in one file is fine. I think we'll
add elements and work with the pages in individual files anyway, if the application is large enough.
Best Answer10-06-2017 05:24
10-06-2017 05:24
If you check out the Bart example app, there is an updateUi method/function that shows you how to swap ui elements, it's pretty straightforward, I just checked it out.
Best Answer10-06-2017 05:26
Fitbit Developers oversee the SDK and API forums. We're here to answer questions about Fitbit developer tools, assist with projects, and make sure your voice is heard by the development team.
10-06-2017 05:26
@SunsetRunner wrote:
Now can i hide my first view, but my second view doesnt work.
You must have something else wrong with your code. Perhaps something else with the same ID?
This works:
https://gist.github.com/orviwan/39a43be3e19a19baf12b577c5e45a074
10-07-2017 07:02
10-07-2017 07:02
Thanks John my mistake was in the file "index.gui"..
I wrote...
<svg id="main" display="inline"><text>MAIN</text></svg>
<svg id="info" display="none"><text>INFO</text></svg>
instead of ...
<svg> <svg id="main" display="inline"><text>MAIN</text></svg> <svg id="info" display="none"><text>INFO</text></svg> </svg>
Best Answer10-16-2017 11:59
10-16-2017 11:59
Sorry, I just don't exactly how to realize several views...
Is that the correct way - as an example:
<svg>
<svg id="view1" display="inline"><text id="duration" x="50%" text-anchor = "middle" y="70" class="updated">000</text></svg>
<svg id="view1" display="inline"><text id="hrm" x="50%" text-anchor = "middle" y="155" class="large-value">xxxx</text></svg>
<svg id="view2" display="none"> <text id="updated" x="50%" text-anchor = "middle" y="220" class="updated">now!</text></svg>
</svg>
does this code create two views with the text-elements "duration" and "hrm" shown on view1 and "updated" on view2?
Best Answer10-16-2017 15:19
10-16-2017 15:19
You have a lot of options on how you want to do this...
but with your code
<svg>
<svg id="view1" display="inline">
//stuff for your first page here
</svg>
<svg id="view2" display="none">
//second page here
</svg>
//add more pages as you need them
</svg>
//inside of your .js file
var v1 = document.getElementById("view1");
var v2 = document.getElementById("view2");
//declare more pages as you need them
//one way to update your pages
function updatePages(view){
switch(view){
case "view1": v2.style.display = "none";
v1.style.display = "inline";
break;
case "view2": v1.style.display = "none";
v2.style.display = "inline";
break;
}
}
10-16-2017 20:16 - edited 10-16-2017 20:17
10-16-2017 20:16 - edited 10-16-2017 20:17
Thanks a lot, Bastion!
Best Answer