knockout-2.0.0 breaks FullHeight example of Steve

239 views
Skip to first unread message

tarlano

unread,
Dec 22, 2011, 8:13:08 PM12/22/11
to KnockoutJS
I am reporting a error when using the new knockout-2.0.0.js release
with Steve Sandersons Full-height app layout series.

http://blog.stevensanderson.com/2011/11/04/full-height-app-layouts-navigation-and-history/

I am not sure if this is a bug with the final release or just
something that changed in the final release, since his code was
originally using knockout-1.3.0beta.js, but I thought you might like
to know that the new knockout-2.0.0.js release crashes his sample.

What I see in the VS2010 debugger is that at line 1893 of
knockout-2.0.0.debug.js after clicking on Places -> America's to
transition to the children pane of the sample that VS2010 reports
"Microsoft JScript runtime error: Unable to get value of the property
'nodeType': object is null or undefined".

Here is the code in question.

// Retrieving binding context from arbitrary nodes
ko.contextFor = function(node) {
// We can only do something meaningful for elements and
comment nodes (in particular, not text nodes, as IE can't store
domdata for them)
switch (node.nodeType) {
case 1:
case 8:
var context = ko.storedBindingContextForNode(node);
if (context) return context;
if (node.parentNode) return
ko.contextFor(node.parentNode);
break;
}

Thanks,

Anthony

tarlano

unread,
Dec 22, 2011, 10:15:34 PM12/22/11
to KnockoutJS
I found a work around to the problem. All you have to do is change one
line in the navigate function, since the first arguement has neither a
srcElement attribute or a target attribute, but still has the required
childLocation and id. I don't exactly know why the rest of the
attributes are missing or if the logic to use dataFor was required,
but it seems to work for me after initial testing..

so the workaround is...

this.navigate = function (evt) {
//var destination = ko.dataFor(evt.srcElement
|| evt.target);
var destination = evt;
if (destination.childLocations.length)
this.paneHistory.navigate({ location:
destination.id });
}


On Dec 22, 5:13 pm, tarlano <tarl...@gmail.com> wrote:
> I am reporting a error when using the new knockout-2.0.0.js release
> with Steve Sandersons Full-height app layout series.
>
> http://blog.stevensanderson.com/2011/11/04/full-height-app-layouts-na...
Reply all
Reply to author
Forward
0 new messages