Skip to content

Commit

Permalink
Find wildcard pages. issue #90
Browse files Browse the repository at this point in the history
  • Loading branch information
finnsson committed Feb 16, 2013
1 parent b496e4a commit 335ee98
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
11 changes: 10 additions & 1 deletion pager.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -818,6 +818,15 @@
return this.val('id'); 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 * @method pager.Page#sourceUrl
Expand Down Expand Up @@ -1149,7 +1158,7 @@
if (!me._child[key]) { if (!me._child[key]) {
me._child[key] = ko.computed(function () { me._child[key] = ko.computed(function () {
var child = $.grep(this.children(), function (c) { var child = $.grep(this.children(), function (c) {
return c.getId() === key; return c.id() === key;
})[0]; })[0];
return child || this.nullObject; return child || this.nullObject;
}, this); }, this);
Expand Down
28 changes: 27 additions & 1 deletion test/should_find_relative_and_absolute_page.html
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -36,9 +36,14 @@
<div id="y_2" data-bind="page: {id: 'y2'}"> <div id="y_2" data-bind="page: {id: 'y2'}">
<div id="i" data-bind="text: $page.find$('/x/x1')().d()"></div> <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="j" data-bind="text: $page.find$('/x/x2')().d()"></div>
<div id="k" data-bind="text: $page.find$('/42')().d()"></div>
</div> </div>
</div> </div>


<div id="w" data-bind="page: {id: '?'}">
<div id="w_text">Wildcard</div>
</div>



<script type="text/javascript"> <script type="text/javascript">


Expand Down Expand Up @@ -75,7 +80,28 @@
assert.equal($('#h').text(), 'x/x2'); assert.equal($('#h').text(), 'x/x2');
assert.equal($('#i').text(), 'x/x1'); assert.equal($('#i').text(), 'x/x1');
assert.equal($('#j').text(), 'x/x2'); 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();
});

});

}); });
}); });
}); });
Expand Down

0 comments on commit 335ee98

Please sign in to comment.