Last active
August 29, 2015 14:25
-
-
Save Craga89/add43ae8b5f245b29ec7 to your computer and use it in GitHub Desktop.
Durandal + Webpack: Part 2 - Composition
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Locates the view, realizes it, binds it to the parent binding context and composes it into the DOM node on which the binding is declared. | |
| data-bind="compose: 'myView.html'" | |
| // Uses RequireJS to get the shell module, locates the view conventionally, binds it and injects it into the DOM node on which the binding is declared. | |
| data-bind="compose: 'shell'" | |
| // Evaluates the binding to obtain the result of someProperty. If it is a string, assume it's a view, otherwise assume it's a viewmodel, and follow the steps above | |
| data-bind="compose: someProperty" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var jQuery = require('jquery'); | |
| var viewEngine = require('durandal/viewEngine'); | |
| var ViewModel = { | |
| getView: function() { | |
| var view = require('./view'); | |
| return viewEngine.processMarkup(view); | |
| } | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function cb(err?: Error, module: Object|Function) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| system.acquire = function(moduleId: String) {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!-- Composes and binds the View HTML stored in the `myView` property into this view --> | |
| <div data-bind="compose: myView"></div> | |
| <!-- Composes the ViewModel stored in the `myViewModel` property into this view --> | |
| <div data-bind="compose: myView"></div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| viewLocator.locateView = function( | |
| viewOrUrlOrId: String|DOMElement, | |
| area?: String, | |
| elementsToSearch?: DOMElement[] | |
| ) {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var jQuery = require('jquery'); | |
| var viewEngine = require('durandal/viewEngine'); | |
| var ViewModel = { | |
| myView: require('./myView.html'), | |
| myViewModel: require('./myViewModel'), | |
| getView: function() { | |
| var view = require('./view'); | |
| return viewEngine.processMarkup(view); | |
| } | |
| }; | |
| module.exports = ViewModel; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment