You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The jsFiddle I created for issue 167 also displays another issue, that of child page links created when using the page-href binding.
If you have a page, call it listing, which has a querystring parameter called testId, and it has two child pages, call them child1 and child2, if you use page-href to generate the link to the children, like this:
<a data-bind="page-href: 'child1'">Go To Child1 Page</a>
<a data-bind="page-href: 'child2'">Go To Child2 Page</a>
as that seems the more natural way to do it to me. I'd also hazard a guess that the current method would result in the testId querystring parameter having a value of 1/child1, so if that child page had a withOnshow method that relied on the querystring parameter, it wouldn't work.
It seems that the issue is that the querystring parameter should be stripped out of the generated route, and if you want it put back in, then use the params option.
I've managed to get it to initially work by adding to the p.path method:
var fullRoute = me.getFullRoute()();
var parentPath = fullRoute.slice(0, fullRoute.length - parentsToTrim).join('/');
var querystring = '';
var querystringStart = parentPath.indexOf('?');
if (querystringStart !== -1) {
var nextSlash = parentPath.indexOf('/', querystringStart);
if (nextSlash !== -1) {
querystring = parentPath.slice(querystringStart, nextSlash);
parentPath = parentPath.replace(querystring, '');
} else {
querystring = parentPath.slice(querystringStart);
parentPath = parentPath.replace(querystring, '');
}
}
var fullPathWithoutHash = (parentPath === '' ? '' : parentPath + '/') + p;
As I said, this does produce the correct links in the page. Can you think of any potential pitfalls with this approach?
The jsFiddle I created for issue 167 also displays another issue, that of child page links created when using the page-href binding.
If you have a page, call it listing, which has a querystring parameter called testId, and it has two child pages, call them child1 and child2, if you use page-href to generate the link to the children, like this:
then the links generated will be:
I would expect the links to be:
as that seems the more natural way to do it to me. I'd also hazard a guess that the current method would result in the testId querystring parameter having a value of 1/child1, so if that child page had a withOnshow method that relied on the querystring parameter, it wouldn't work.
I've also tried adding params to the page route:
and this is, if anything, worse:
It seems that the issue is that the querystring parameter should be stripped out of the generated route, and if you want it put back in, then use the params option.
I've managed to get it to initially work by adding to the
p.path
method:As I said, this does produce the correct links in the page. Can you think of any potential pitfalls with this approach?
I've updated the jsFiddle to have two links: http://jsfiddle.net/ry4UK/4/
The text was updated successfully, but these errors were encountered: