Hello,
I am building a desktop app using polymer and so far it has been a blast but, I have hit a roadblock on my project. I am attempting to update the content in the main content div when the user hits the different topics on the side nav. Using the core-scaffold and some of the techniques from the single-page-polymer app example, I have this snippet showing my main div with id="content".
<div layout horizontal center-center fit>
<core-animated-pages id="pages" selected="{{route}}" valueattr="hash" transitions="slide-from-right">
<template repeat="{{page, i in pages}}">
<section hash="{{page.hash}}" layout vertical center-center>
<div>
<div id="content"></div>
</div>
</section>
</template>
</core-animated-pages>
</div>
When someone hits the side nav's it updates the {{route}}, from there I am handling this with the following js:
var that = this;
var pages = document.querySelector('#pages');
that.setContent(pages.selected);
template.setContent = function(view) {
console.log('setContent');
if (view === 'one') {
console.log('dash');
var content = document.getElementById('content');
while (content.firstChild) content.removeChild(content.firstChild);
} else if (view === 'two') {
console.log('post-view');
var content = document.getElementById('content');
while (content.firstChild) content.removeChild(content.firstChild);
var postView = document.createElement('post-view');
content.appendChild(postView);
} ... etc.
Even if I get the {{route}} as 'two' and even if it matches the if (view === 'two') ... it does not display my content. So how would you all recommend handling this? It seems rather sloppy the way I have it, but I need to clear the main area and then put new content in that main area for each of the side navs. And I know I could just write out each section in the html, but what fun is that.
Help me if you can!
Thanks!