I have a Knockout application developed using Durandal.JS. Here is the structure of my project:
- Parent
- Index.js
- Index.html
- Child1
- Index.js
- Index.html
- Child2
- Index.js
- Index.html
I have a function UpdateData() declared in Child2/Index.js and I want to consume that function from Child1/Index.js
Reason of declaring this function in Child2 is, I have other variables and controls declared in Child2. And by calling UpdateData() method, I want to update the value of all variables declared in Child2.
I don't know how to handle this situation.
Durandal by default uses require to load modules. You could try to require the child2 module in your child1 module.
For this to work, you must return the
UpdateData()method fromChild2.For more information, you could go through the docs on how to create a module that can be reused by other modules. http://durandaljs.com/documentation/Creating-A-Module.html