Permalink
Browse files

Find wildcard pages. issue #90

  • Loading branch information...
1 parent b496e4a commit 335ee987e285e9f87015f24cad4ce6d2643035c9 @finnsson committed Feb 16, 2013
Showing with 37 additions and 2 deletions.
  1. +10 −1 pager.js
  2. +27 −1 test/should_find_relative_and_absolute_page.html
View
@@ -818,6 +818,15 @@
return this.val('id');
};
+ p.id = function() {
+ var currentId = this.getCurrentId();
+ if(currentId == null || currentId === '') {
+ return this.getId();
+ } else {
+ return currentId;
+ }
+ };
+
/**
* @method pager.Page#sourceUrl
@@ -1149,7 +1158,7 @@
if (!me._child[key]) {
me._child[key] = ko.computed(function () {
var child = $.grep(this.children(), function (c) {
- return c.getId() === key;
+ return c.id() === key;
})[0];
return child || this.nullObject;
}, this);
@@ -36,9 +36,14 @@
<div id="y_2" data-bind="page: {id: 'y2'}">
<div id="i" data-bind="text: $page.find$('/x/x1')().d()"></div>
<div id="j" data-bind="text: $page.find$('/x/x2')().d()"></div>
+ <div id="k" data-bind="text: $page.find$('/42')().d()"></div>
</div>
</div>
+<div id="w" data-bind="page: {id: '?'}">
+ <div id="w_text">Wildcard</div>
+</div>
+
<script type="text/javascript">
@@ -75,7 +80,28 @@
assert.equal($('#h').text(), 'x/x2');
assert.equal($('#i').text(), 'x/x1');
assert.equal($('#j').text(), 'x/x2');
- start();
+
+
+ location.hash = '#42';
+
+ until(function() {
+ return $('#w_text').is(':visible');
+ }, function() {
+
+ assert.equal($('#k').text(), '42');
+
+ location.hash = '#44';
+
+ until(function() {
+ return $('#k').text() === '';
+ }, function() {
+ assert.equal($('#k').text(), '');
+
+ start();
+ });
+
+ });
+
});
});
});

0 comments on commit 335ee98

Please sign in to comment.