It can be tricky to calculate the absolute path of a link -
especially if you know the page will be loaded form somewhere else.
Just use the page-href
custom binding instead of specifying
a href
directly!
The page-href
link will be relative to the page where the
element is. So if an anchor tag is in the page "user" a value pelle
will be resolved to user/pelle
. The binding also understands ../
if you need to track back up the page hierarchy!
pager.Href.hash
is by default #
but can be changed to #!/
(or any other string). All page-href
bindings will use the prefix from pager.Href.hash
.
<div data-bind="page: {id: 'start'}"> <ul class="nav nav-tabs"> <li class="active"> <a data-bind="page-href: 'fry'">Fry</a> </li> <li class="active"> <a data-bind="page-href: 'interesting'">Interesting</a> </li> </ul> <div data-bind="page: {id: 'fry'}"> <img src="fry.jpg"/> </div> <div data-bind="page: {id: 'interesting'}"> <a data-bind="page-href: '../../'">Close this tab</a> <br/> <img src="interesting.jpg"/> </div> </div>