riot.js - Riot JS unmount all tags in a page and then mount only one tag is not working -
i using riot js , in index.html, have 3 custom tags - header, login-panel , candidates-panel inside body. in main app.js, in callback function of $(document).ready, execute current route , register route change handler function. in switchview, unmount custom tags , try mount tag pertaining current view being switched. here code. if unmount, nothing displayed on page
index.html
<body> <header label="hire zen" icon="img/user-8-32.png"></header> <login-panel class="viewtag" id="loginview"></login-panel> <candidates-panel id="candidatesview" class="viewtag"></candidates-panel> <script src="js/bundle.js"></script> </body>
app.js
function switchview(view) { if(!view || view === '') { view = 'login' } //unmount other panels , mount panel required //todo: unmount view panels , mounting required panel not working //riot.unmount('.viewtag') riot.mount(view+'-panel') $('.viewtag').hide() $(view+'-panel').show() } $(document).ready(function () { riotcontrol.addstore(new authstore()) riotcontrol.addstore(new candidatesstore()) riot.mount('header') //register route change handler riot.route(function (collection, id, action) { switchview(collection) }) riot.route.exec(function (collection, id, action) { switchview(collection) }) })
answer riot.js v2.1.0:
the function
riot.unmount(...)
is not available far know. however, can unmount saved tags.
mytag.unmount(true)
the trick remember mounted tags able unmount them later:
var viewtag = riot.mount(document.getelementbyid('viewtag')) viewtag.unmount(true)
you can store view tags in object , loop them unmount , mount active one.
Comments
Post a Comment