knockout.js - pagerjs - sharing view model with enclosing pages -


if have nested pages

<div data-bind="page: {id: 'top', withonshow: topvm}">   <div data-bind="page: {id: 'sub1', withonshow: sub1vm}">     <span data-bind="text:sub1property"></span>   </div> </div>   topvm = function(callback) { callback({topproperty: xxx}); }  sub1vm = function(callback) {     // how can access topvm here?    callback({sub1property: xxx});  } 

how can access outer page's view model inner page's view model?

<span data-bind="text:$root.topvmproperty"></span> 

the link here explains knockout contexts

http://knockoutjs.com/documentation/binding-context.html

according example this:

<span data-bind="text:$parent[1].topvmproperty"></span> 

Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -