{"id":695,"date":"2017-06-06T18:52:54","date_gmt":"2017-06-06T18:52:54","guid":{"rendered":"http:\/\/bitcows.com\/?p=695"},"modified":"2017-06-06T18:52:54","modified_gmt":"2017-06-06T18:52:54","slug":"back-to-basics-navigationwindow-example","status":"publish","type":"post","link":"https:\/\/bitcows.com\/?p=695","title":{"rendered":"Back to Basics Appcelerator NavigationWindow example"},"content":{"rendered":"<p>There was a question I got a few days ago about how to use the Appcelerator NavigationWindow with multiple layers of navigation. Since I didn&#8217;t find an online answer easily, I figured I would write a quick tutorial on this. <\/p>\n<h3>The Problem<\/h3>\n<p>You have a screen with a few layers of screens you would like to be able to navigate into and back out of using the NavigationWindow control. <\/p>\n<p><img decoding=\"async\" src=\"http:\/\/bitcows.com\/wp-content\/uploads\/2017\/06\/screens.gif\" alt=\"\" width=\"650\"\/><\/p>\n<h3>The Solution<\/h3>\n<p><strong><em>app\/views\/index.xml<\/em><\/strong><br \/>\nThe main <em>NavigtionWindow<\/em> view.<br \/>\nThe important thing here is to notice the <code>nextWin=\"details\"<\/code> Thats the next window I&#8217;m calling.<\/p>\n<pre class=\"prettyprint\">&lt;Alloy&gt;\n    &lt;NavigationWindow platform=\"ios\" id=\"navWindow\"&gt;\n        &lt;Window id=\"main\" title=\"Nav Example\"&gt;\n            &lt;RightNavButton&gt;\n                &lt;Button onClick=\"Alloy.Globals.openWindow\" nextWin=\"details\"&gt;more details&lt;\/Button&gt;\n            &lt;\/RightNavButton&gt;\n            &lt;Label&gt;Main screen want more details?&lt;\/Label&gt;\n        &lt;\/Window&gt;\n    &lt;\/NavigationWindow&gt;\n&lt;\/Alloy&gt;<\/pre>\n<p><strong><em>app\/controllers\/index.js<\/em><\/strong><br \/>\nHere we need to do one thing and thats set a <em>navwindow<\/em> globally to access here its the <code>$.navWindow<\/code>.<\/p>\n<pre class=\"prettyprint\">Alloy.Globals.navwindow = $.navWindow; \/\/ The id of the NavigtionWindow\n\n$.navWindow.open();<\/pre>\n<p><strong><em>app\/alloy.js<\/em><\/strong><br \/>\nNow here we pick up that nextWin variable I set.<\/p>\n<pre class=\"prettyprint\">Alloy.Globals = {\n    openWindow: function(e) {    \n        \/\/ This gets the next window name thats defined in the XML\n        var nextWin = e.source.nextWin;\n        \/\/ Push it on the navigagtion stack\n        Alloy.Globals.navwindow.openWindow(Alloy.createController(nexWin).getView());\n    }\n};<\/pre>\n<p><strong><em>\/apps\/views\/details.xml<\/em><\/strong><br \/>\nThe first details screen notice the next screen is denoted <code>nextWin=\"moredetails\"<\/code><\/p>\n<pre class=\"prettyprint\">&lt;Alloy&gt;\n    &lt;Window id=\"details\" backgroundColor=\"white\"&gt;\n        &lt;RightNavButton&gt;\n            &lt;Button onClick=\"Alloy.Globals.openWindow\" nextWin=\"moredetails\"&gt;even more details&lt;\/Button&gt;\n        &lt;\/RightNavButton&gt;\n        &lt;Label&gt;Here is a detail screen.&lt;\/Label&gt;       \n    &lt;\/Window&gt;\n&lt;\/Alloy&gt;<\/pre>\n<p><strong><em>\/apps\/views\/moredetails.xml<\/em><\/strong><br \/>\nThe second more details screen<\/p>\n<pre class=\"prettyprint\">&lt;Alloy&gt;\n    &lt;Window id=\"moredetails\" backgroundColor=\"white\"&gt;\n        &lt;Label&gt;Here is more details screen.&lt;\/Label&gt;       \n    &lt;\/Window&gt;\n&lt;\/Alloy&gt;<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>There was a question I got a few days ago about how to use the Appcelerator NavigationWindow with multiple layers of navigation. Since I didn&#8217;t find an online answer easily, I figured I would write a quick tutorial on this. The Problem You have a screen with a few layers of screens you would like&hellip;<\/p>\n<p class=\"more-link\"><a href=\"https:\/\/bitcows.com\/?p=695\" class=\"themebutton\">Read More<\/a><\/p>\n","protected":false},"author":1,"featured_media":617,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,15],"tags":[32,49],"class_list":["post-695","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-appcelerator","category-ios","tag-appc","tag-ios-2"],"_links":{"self":[{"href":"https:\/\/bitcows.com\/index.php?rest_route=\/wp\/v2\/posts\/695","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bitcows.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bitcows.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bitcows.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/bitcows.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=695"}],"version-history":[{"count":0,"href":"https:\/\/bitcows.com\/index.php?rest_route=\/wp\/v2\/posts\/695\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/bitcows.com\/index.php?rest_route=\/"}],"wp:attachment":[{"href":"https:\/\/bitcows.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=695"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bitcows.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=695"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bitcows.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=695"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}