examples/HTML StarterKit/lib/durandal/js/composition.js
function (element, settings, bindingContext, fromBinding) {
            compositionCount++;

            if(!fromBinding){
                settings = composition.getSettings(function() { return settings; }, element);
            }

            if (settings.compositionComplete) {
                compositionCompleteCallbacks.push(function () {
                    settings.compositionComplete(settings.child, settings.parent, settings);
                });
            }

            compositionCompleteCallbacks.push(function () {
                if(settings.composingNewView && settings.model && settings.model.compositionComplete){
                    settings.model.compositionComplete(settings.child, settings.parent, settings);
                }
            });

            var hostState = getHostState(element);

            settings.activeView = hostState.activeView;
            settings.parent = element;
            settings.triggerAttach = triggerAttach;
            settings.bindingContext = bindingContext;

            if (settings.cacheViews && !settings.viewElements) {
                settings.viewElements = hostState.childElements;
            }

            if (!settings.model) {
                if (!settings.view) {
                    this.bindAndShow(null, settings);
                } else {
                    settings.area = settings.area || 'partial';
                    settings.preserveContext = true;

                    viewLocator.locateView(settings.view, settings.area, settings.viewElements).then(function (child) {
                        composition.bindAndShow(child, settings);
                    });
                }
            } else if (system.isString(settings.model)) {
                system.acquire(settings.model).then(function (module) {
                    settings.model = system.resolveObject(module);
                    composition.inject(settings);
                }).fail(function(err){
                    system.error('Failed to load composed module (' + settings.model + '). Details: ' + err.message);
                });
            } else {
                composition.inject(settings);
            }
        }
function (element, settings, bindingContext, fromBinding) {
            compositionCount++;

            if(!fromBinding){
                settings = composition.getSettings(function() { return settings; }, element);
            }

            if (settings.compositionComplete) {
                compositionCompleteCallbacks.push(function () {
                    settings.compositionComplete(settings.child, settings.parent, settings);
                });
            }

            compositionCompleteCallbacks.push(function () {
                if(settings.composingNewView && settings.model && settings.model.compositionComplete){
                    settings.model.compositionComplete(settings.child, settings.parent, settings);
                }
            });

            var hostState = getHostState(element);

            settings.activeView = hostState.activeView;
            settings.parent = element;
            settings.triggerAttach = triggerAttach;
            settings.bindingContext = bindingContext;

            if (settings.cacheViews && !settings.viewElements) {
                settings.viewElements = hostState.childElements;
            }

            if (!settings.model) {
                if (!settings.view) {
                    this.bindAndShow(null, settings);
                } else {
                    settings.area = settings.area || 'partial';
                    settings.preserveContext = true;

                    viewLocator.locateView(settings.view, settings.area, settings.viewElements).then(function (child) {
                        composition.bindAndShow(child, settings);
                    });
                }
            } else if (system.isString(settings.model)) {
                system.acquire(settings.model).then(function (module) {
                    settings.model = system.resolveObject(module);
                    composition.inject(settings);
                }).fail(function(err){
                    system.error('Failed to load composed module (' + settings.model + '). Details: ' + err.message);
                });
            } else {
                composition.inject(settings);
            }
        }
function ( element , settings , bindingContext , fromBinding ) { compositionCount ++ ; if ( ! fromBinding ) { settings = composition . getSettings ( function ( ) { return settings ; } , element ) ; } if ( settings . compositionComplete ) { compositionCompleteCallbacks . push ( function ( ) { settings . compositionComplete ( settings . child , settings . parent , settings ) ; } ) ; } compositionCompleteCallbacks . push ( function ( ) { if ( settings . composingNewView && settings . model && settings . model . compositionComplete ) { settings . model . compositionComplete ( settings . child , settings . parent , settings ) ; } } ) ; var hostState = getHostState ( element ) ; settings . activeView = hostState . activeView ; settings . parent = element ; settings . triggerAttach = triggerAttach ; settings . bindingContext = bindingContext ; if ( settings . cacheViews && ! settings . viewElements ) { settings . viewElements = hostState . childElements ; } if ( ! settings . model ) { if ( ! settings . view ) { this . bindAndShow ( null , settings ) ; } else { settings . area = settings . area || 'partial' ; settings . preserveContext = true ; viewLocator . locateView ( settings . view , settings . area , settings . viewElements ) . then ( function ( child ) { composition . bindAndShow ( child , settings ) ; } ) ; } } else if ( system . isString ( settings . model ) ) { system . acquire ( settings . model ) . then ( function ( module ) { settings . model = system . resolveObject ( module ) ; composition . inject ( settings ) ; } ) . fail ( function ( err ) { system . error ( 'Failed to load composed module (' + settings . model + '). Details: ' + err . message ) ; } ) ; } else { composition . inject ( settings ) ; } }
Initiates a composition.
@method compose
@param {DOMElement} element The DOMElement or knockout virtual element that serves as the parent for the composition.
@param {object} settings The composition settings.
@param {object} [bindingContext] The current binding context.
Initiates a composition .