UNPKG

can

Version:

MIT-licensed, client-side, JavaScript framework that makes building rich web applications easy.

948 lines (637 loc) 31.3 kB
<!DOCTYPE html> <!--#################################################################### THIS IS A GENERATED FILE -- ANY CHANGES MADE WILL BE OVERWRITTEN INSTEAD CHANGE: source: [object Object] @property can-component.prototype.ViewModel ######################################################################## --> <html lang="en"> <head> <meta charset="utf-8"> <title>CanJS - ViewModel</title> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"> <link rel="stylesheet" type="text/css" href="./static/bundles/bit-docs-site/static.css"> <link rel="shortcut icon" sizes="16x16 24x24 32x32 48x48 64x64" href="/docs/images/canjs_favicon.ico"> <link rel="apple-touch-icon" sizes="57x57" href="../docs/images/canjs_favicon_57x57.png"> <link rel="apple-touch-icon-precomposed" sizes="57x57" href="../docs/images/canjs_favicon_57x57.png"> <link rel="apple-touch-icon" sizes="72x72" href="../docs/images/canjs_favicon_72x72.png"> <link rel="apple-touch-icon" sizes="114x114" href="../docs/images/canjs_favicon_114x114.png"> <link rel="apple-touch-icon" sizes="120x120" href="../docs/images/canjs_favicon_128x128.png"> <link rel="apple-touch-icon" sizes="144x144" href="../docs/images/canjs_favicon_144x144.png"> <link rel="apple-touch-icon" sizes="152x152" href="../docs/images/canjs_favicon_152x152.png"> <meta content="yes" name="apple-mobile-web-app-capable"> <meta name="apple-mobile-web-app-status-bar-style" content="white-translucent"> <script> (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','https://www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-2302003-11', 'auto'); ga('send', 'pageview'); </script> </head> <body> <input type="checkbox" id="nav-trigger" class="nav-trigger"/> <label for="nav-trigger">Menu</label> <div id="everything"> <div id="left" class="column"> <div class="top-left"> <div class="brand"> <div class="logo"> <a href="../index.html" alt="CanJS"></a> <div class="dropdown project-dropdown"> <a href="https://donejs.com/">DoneJS</a> <a href="http://stealjs.com/">StealJS</a> <a href="http://jquerypp.com/">jQuery ++</a> <a href="https://funcunit.com/">FuncUnit</a> <a href="http://documentjs.com/">DocumentJS</a> </div> </div> <div class="version"> <div class="version-number"> 3.0.0 </div> <div class="dropdown version-dropdown"> <a href="https://v2.canjs.com">2.3.27</a> </div> </div> </div> <div class="search-bar"> <p> &nbsp; </p> </div> </div> <div class="bottom-left"> <div class="social-side-container"> <ul class="social-side"> <li> <a class="header-mobile github" href="https://github.com/canjs/canjs" target="_blank"><img class="social-icon-small" src="../docs/images/github.png">Github</a> </li> <li> <a class="header-mobile twitter" href="https://twitter.com/canjs" target="_blank"><img class="social-icon-small" src="../docs/images/twitter.png">Twitter</a> </li> </ul> <ul class="social-side"> <li> <a class="header-mobile" href="https://gitter.im/canjs/canjs" target="_blank">Chat</a> </li> <li> <a class="header-mobile" href="http://forums.donejs.com/c/canjs" target="_blank">Forum</a> </li> </ul> </div> <ul> <li class=" "> <a class="page" href="guides.html" title="Welcome to CanJS! These guides are here to help you develop and improve your relationship with CanJS. After all, picking a JavaScript framework is a commitment. We want CanJS to be the framework you marry. This page helps you know how advance through the different stages of this relationship:"> Guides </a> </li> <li class=" parent expanded"> <a class="page" href="can-core.html" title="The best, most hardened and generally useful libraries in CanJS."> Core </a> <ul> <li class=" parent expanded"> <a class="module" href="can-component.html" title="Create a custom element that can be used to manage widgets or application logic."> can-component </a> <ul> <li> <span>static</span> <ul> <li class=" "> <a class="function" href="can-component.extend.html" title="Define the behavior of a custom element."> extend </a> </li> </ul> </li> <li> <span>prototype</span> <ul> <li class="current parent expanded"> <a class="property" href="can-component.prototype.ViewModel.html" title="Provides or describes a constructor function that provides values and methods to the component&#x27;s template. The constructor function is initialized with values specified by the component element&#x27;s data bindings."> ViewModel </a> </li> <li class=" "> <a class="property" href="can-component.prototype.events.html" title="Listen to events on elements and observables."> events </a> </li> <li class=" "> <a class="property" href="can-component.prototype.helpers.html" title="Helper functions used with the component&#x27;s template."> helpers </a> </li> <li class=" "> <a class="property" href="can-component.prototype.leakScope.html" title="Allow reading the outer scope values from a component&#x27;s template and a component&#x27;s viewModel values in the user content."> leakScope </a> </li> <li class=" "> <a class="property" href="can-component.prototype.tag.html" title="Specifies the HTML tag (or node-name) the can-component will be created on."> tag </a> </li> <li class=" "> <a class="property" href="can-component.prototype.view.html" title="Provides a template to render directly within the component&#x27;s element. The template is rendered with the component&#x27;s can-component::ViewModel instance. &lt;content/&gt; elements within the template are replaced by the source elements within the component&#x27;s tag."> view </a> </li> <li class=" "> <a class="function" href="can-component.prototype.view-model.html" title="Return the view model instance or type with which the component&#x27;s can-component.prototype.view is rendered. This is used when more fine grained control is needed over can-component::ViewModel."> viewModel </a> </li> </ul> </li> <li> <span>elements</span> <ul> <li class=" "> <a class="typedef" href="can-component/content.html" title="Positions the LIGHT_DOM within a component&#x27;s can-component.prototype.template."> &lt;content&gt; </a> </li> </ul> </li> <li> <span>special events</span> <ul> <li class=" "> <a class="typedef" href="can-component/beforeremove.html" title="An event called only on component&#x27;s elements before they are removed from the document if live binding is performing the removal. It can be listened to within a component&#x27;s can-component.prototype.events object or on a component element with can-stache-bindings.event bindings. This is an additional special event only on component elements. inserted and removed events are available on all elements."> beforeremove </a> </li> </ul> </li> </ul> </li> <li class=" "> <a class="module" href="can-compute.html" title="Create an observable value."> can-compute </a> </li> <li class=" "> <a class="module" href="can-connect.html" title="can-connect provides persisted data middleware. Use it to assemble powerful model layers for any JavaScript project."> can-connect </a> </li> <li class=" "> <a class="module" href="can-define.html" title="Exports the define method that defines observable properties and their behavior on a prototype object."> can-define </a> </li> <li class=" "> <a class="module" href="can-define/list/list.html" title="Create observable lists."> can-define/list/list </a> </li> <li class=" "> <a class="module" href="can-define/map/map.html" title="Create observable objects."> can-define/map/map </a> </li> <li class=" "> <a class="function" href="can-route.html" title="Manage browser history and client state by synchronizing the window.location.hash with a map."> can-route </a> </li> <li class=" "> <a class="module" href="can-route-pushstate.html" title="Changes can-route to use pushstate to change the window&#x27;s pathname instead of the hash. var route = require(&quot;can-route-pushstate&quot;); route(&quot;{page}&quot;, { page: &quot;home&quot; }); route.ready(); route.attr(&quot;page&quot;, &quot;user&quot;); location.pathname; // -&gt; &quot;/user&quot;"> can-route-pushstate </a> </li> <li class=" "> <a class="module" href="can-set.html" title="can-set is a utility for comparing sets that are represented by the parameters commonly passed to service requests."> can-set </a> </li> <li class=" "> <a class="module" href="can-stache.html" title="Live binding Mustache and Handlebars-compatible templates."> can-stache </a> </li> <li class=" "> <a class="module" href="can-stache/helpers/route.html" title="Adds stache helpers that use can-route."> can-stache/helpers/route </a> </li> <li class=" "> <a class="module" href="can-stache-bindings.html" title="Provides template event, one-way, and two-way bindings."> can-stache-bindings </a> </li> </ul> </li> <li class=" "> <a class="page" href="can-ecosystem.html" title="Useful libraries that extend or add important features to the core collection."> Ecosystem </a> </li> <li class=" "> <a class="page" href="can-infrastructure.html" title="Utility libraries that power the core and ecosystem collection."> Infrastructure </a> </li> <li class=" "> <a class="page" href="can-legacy.html" title="Former libraries that we still accept patches for, but are not under active development."> Legacy </a> </li> </ul> </div> </div> <div id="right" class="column"> <div class="top-right"> <div class="top-right-top"> <ul class="top-right-bitovi"> <li class="dropdown"> <a href="http://bitovi.com" class="bitovi icon-bits">Bitovi</a> <ul class="dropdown-menu"> <li><a href="http://bitovi.com">Bitovi.com</a></li> <li><a href="http://bitovi.com/blog/">Blog</a></li> <li><a href="http://bitovi.com/consulting/">Consulting</a></li> <li><a href="http://bitovi.com/training/">Training</a></li> <li><a href="http://bitovi.com/open-source/">Open Source</a></li> </ul> </li> </ul> <div class="brand"> <div class="logo"> <a href="../index.html" alt="CanJS"></a> </div> </div> <ul class="top-right-links"> <li> <a href="https://gitter.im/canjs/canjs">Chat</a> </li> <li> <a href="http://forums.donejs.com/c/canjs">Forum</a> </li> <li> <a class="github-button nav-social" href="https://github.com/canjs/canjs" data-count-href="/canjs/canjs/stargazers" data-count-api="/repos/canjs/canjs#stargazers_count">Star</a> </li> <li> <a href="https://twitter.com/canjs" class="twitter-follow-button nav-social" data-show-count="true" data-show-screen-name="false">Follow @canjs</a><script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script> </li> </ul> </div> <div class="breadcrumb"> <li><a href="../index.html">CanJS</a></li> / <li><a href="can-core.html">Core</a></li> / <li><a href="can-component.html">can-component</a></li> / <li><a href="can-component.prototype.ViewModel.html">ViewModel</a></li> <li class="breadcrumb-dropdown">/ <a> On this page</a> <ul class="on-this-page"></ul> </li> <div class="nav-toggle" title="Back to top"></div> </div> </div> <div class="bottom-right"> <article> <section class="title"> <div class="page-type"> <h1>ViewModel</h1> <div>property</div> </div> <section class="description"> <p>Provides or describes a constructor function that provides values and methods to the component's <a href="can-component.prototype.view.html" title="Provides a template to render directly within the component's element. The template is rendered with the component's can-component::ViewModel instance. &lt;content/&gt; elements within the template are replaced by the source elements within the component's tag.">template</a>. The constructor function is initialized with values specified by the component element's <a href="can-stache-bindings.html" title="Provides template event, one-way, and two-way bindings.">data bindings</a>.</p> </section> </section> <section class="on-this-page-table"> </section> <section class="title-footer"> <ul class="title-links"> <!-- <li><a href="#">docco</a></li> --> <li><a href="//github.com/canjs/can-component/tree/v3.0.2/docs/ViewModel.md">source</a></li> <!-- <li><a href="#">download</a></li> --> <!-- <li><a href="#">tests</a></li> --> </ul> </section> <div class="signature"> <h2 class="signature-title"> <code>function(properties)</code> </h2> <p>A constructor function usually defined by <a href="can-define/map/map.extend.html" title="Define a custom map type.">DefineMap.extend</a> or <a href="can-map.html" title="Create observable objects.">Map.extend</a> that will be used to create an new observable instance accessible by the component's <a href="can-component.prototype.view.html" title="Provides a template to render directly within the component's element. The template is rendered with the component's can-component::ViewModel instance. &lt;content/&gt; elements within the template are replaced by the source elements within the component's tag.">view</a>.</p> <p>For example, every time <code>&lt;my-tag&gt;</code> is found, a new instance of <code>MyTagViewModel</code> will be created:</p> <pre><code class="language-js">var MyTagViewModel = DefineMap.extend(&quot;MyTagViewModel&quot;,{ message: &quot;string&quot; }); Component.extend({ tag: &quot;my-tag&quot;, ViewModel: MyTagViewModel, view: stache(&quot;&lt;h1&gt;{{message}}&lt;/h1&gt;&quot;) }) </code></pre> <p>Use <a href="can-view-model.html" title="Gets the ViewModel of an element.">can-view-model</a> to read a component's view model instance.</p> <div class="parameters"> <h3 class="parameters-title">Parameters</h3> <ol> <li><b>properties</b> <code>{Object}</code>: <p>The initial properties that are passed by the <a href="can-stache-bindings.html" title="Provides template event, one-way, and two-way bindings.">data bindings</a>.</p> <p>The view bindings on a tag control the properties and values used to instantiate the <code>ViewModel</code>. For example, calling <code>&lt;my-tag&gt;</code> as follows invokes <code>MyTagViewModel</code> as shown in the following example:</p> <pre><code>&lt;my-tag/&gt; &lt;!-- new MyTagViewModel({}) --&gt; &lt;my-tag {message}=&quot;'Hi There'&quot;/&gt; &lt;!-- new MyTagViewModel({message: &quot;Hi There&quot;}) --&gt; </code></pre> </li> </ol> </div> <div class="returns"> <h3 class="returns-title">Returns</h3> <p> <code>{Object}</code>: <p>A new instance of the corresponding constructor function. This instance is added to the top of the <a href="can-view-scope.html" title="Create a lookup node for keys.">can-view-scope</a> the component's <a href="can-component.prototype.view.html" title="Provides a template to render directly within the component's element. The template is rendered with the component's can-component::ViewModel instance. &lt;content/&gt; elements within the template are replaced by the source elements within the component's tag.">view</a> is rendered with.</p> </p> </div> </div> <section class="body"> <h2>Use</h2> <p><a href="can-component.html" title="Create a custom element that can be used to manage widgets or application logic.">can-component</a>'s ViewModel property is used to create an <strong>object</strong>, typically an instance of a <a href="can-define/map/map.html" title="Create observable objects.">can-define/map/map</a>, that will be used to render the component's template. This is most easily understood with an example. The following component shows the current page number based off a <code>limit</code> and <code>offset</code> value:</p> <pre><code class="language-js">var MyPaginateViewModel = DefineMap.extend({ offset: {value: 0}, limit: {value: 20}, get page() { return Math.floor(this.offset / this.limit) + 1; } }); Component.extend({ tag: &quot;my-paginate&quot;, ViewModel: MyPaginateViewModel, view: stache(&quot;Page {{page}}.&quot;) }) </code></pre> <p>If this component HTML was inserted into the page like:</p> <pre><code class="language-js">var template = stache(&quot;&lt;my-paginate/&gt;&quot;); var frag = template(); document.body.appendChild(frag); </code></pre> <p>It would result in:</p> <pre><code>&lt;my-paginate&gt;Page 1&lt;/my-paginate&gt; </code></pre> <p>This is because the provided ViewModel object is used to create an instance of <a href="can-define/map/map.html" title="Create observable objects.">can-define/map/map</a> like:</p> <pre><code class="language-js">var viewModel = new MyPaginateViewModel(); </code></pre> <p>The <a href="can-define.types.value.html" title="Returns the default value for instances of the defined type. The default value is defined on demand, when the property is read for the first time.">value</a> property definition makes offset default to 0 and limit default to 20.</p> <p>Next, the values are passed into <code>viewModel</code> from the <a href="can-stache-bindings.html" title="Provides template event, one-way, and two-way bindings.">data bindings</a> within <code>&lt;my-paginate&gt;</code> (in this case there is none).</p> <p>And finally, that data is used to render the component's template and inserted into the element using <a href="can-view-scope.html" title="Create a lookup node for keys.">can-view-scope</a> and <a href="can-stache.html" title="Live binding Mustache and Handlebars-compatible templates.">can-stache</a>:</p> <pre><code class="language-js">var newViewModel = new Scope(viewModel), result = stache(&quot;Page {{page}}.&quot;)(newViewModel); element.innerHTML = result; </code></pre> <p>There is a short-hand for the prototype methods and properties used to extend the <a href="can-util/js/types/types.DefaultMap.html" title="">default Map type</a> (typically <a href="can-define/map/map.html" title="Create observable objects.">can-define/map/map</a>) by setting the Component's ViewModel to an object and using that anonymous type as the view model.</p> <p>The following does the same as above:</p> <pre><code class="language-js">Component.extend({ tag: &quot;my-paginate&quot;, ViewModel: { offset: {value: 0}, limit: {value: 20}, get page() { return Math.floor(this.offset / this.limit) + 1; } }, view: stache(&quot;Page {{page}}.&quot;) }) </code></pre> <h2>Values passed from attributes</h2> <p>Values can be &quot;passed&quot; into the viewModel instance of a component, similar to passing arguments into a function. Using <a href="can-stache-bindings.html" title="Provides template event, one-way, and two-way bindings.">can-stache-bindings</a>, the following binding types can be setup:</p> <ul> <li><a href="can-stache-bindings.toChild.html" title="One-way bind a value in the parent scope to the viewModel.">{to-child}</a> - Update the component's viewModel instance when the parent scope value changes.</li> <li><a href="can-stache-bindings.toParent.html" title="One-way bind a value in the current viewModel to the parent scope.">{^to-parent}</a> - Update the parent scope when the component's viewModel instance changes.</li> <li><a href="can-stache-bindings.twoWay.html" title="Two-way bind a value in the viewModel or the element to the parent scope.">{(two-way)}</a> - Update the parent scope or the component's viewModel instance when the other changes.</li> </ul> <p>Using <a href="can-stache.html" title="Live binding Mustache and Handlebars-compatible templates.">can-stache</a>, values are passed into components like this:</p> <pre><code>&lt;my-paginate {offset}='index' {limit}='size' /&gt; </code></pre> <p>The above creates an offset and limit property on the component that are initialized to whatever index and size are.</p> <p>The following component requires an <code>offset</code> and <code>limit</code>:</p> <pre><code class="language-js">Component.extend({ tag: &quot;my-paginate&quot;, ViewModel: { offset: {value: 0}, limit: {value: 20}, get page() { return Math.floor(this.offset / this.limit) + 1; } }, view: stache(&quot;Page {{page}}.&quot;) }); </code></pre> <p>If <code>&lt;my-paginate&gt;</code> is used like:</p> <pre><code class="language-js">var template = stache(&quot;&lt;my-paginate {offset}='index' {limit}='size' /&gt;&quot;); var pageInfo = new DefineMap({index: 0, size: 20}); document.body.appendChild(template(pageInfo)); </code></pre> <p>... <code>pageInfo</code>'s index and size are set as the component's offset and limit attributes. If we were to change the value of <code>pageInfo</code>'s index like:</p> <pre><code class="language-js">pageInfo.index = 20; </code></pre> <p>... the component's offset value will change and its template will update to:</p> <pre><code>&lt;my-paginate&gt;Page 2&lt;/my-paginate&gt; </code></pre> <h3>Using attribute values</h3> <p>You can also pass a literal string value of the attribute. To do this in <a href="can-stache.html" title="Live binding Mustache and Handlebars-compatible templates.">can-stache</a>, simply pass any value not wrapped in single brackets, and the viewModel instance property will be initialized to this string value:</p> <pre><code>&lt;my-tag title=&quot;hello&quot; /&gt; </code></pre> <p>The above will set the title property on the component's viewModel instance to the string <code>hello</code>.</p> <p>If the tag's <code>title</code> attribute is changed, it updates the viewModel instance property automatically. This can be seen in the following example:</p> <div class='demo_wrapper' data-demo-src='demos/can-component/accordion.html'></div> <p>Clicking the <strong>Change title</strong> button sets a <code>&lt;panel&gt;</code> element's <code>title</code> attribute like:</p> <pre><code class="language-js">out.addEventListener(&quot;click&quot;, function(ev){ var el = ev.target; var parent = el.parentNode; if(el.nodeName === &quot;BUTTON&quot;) { parent.setAttribute(&quot;title&quot;, &quot;Users&quot;); parent.removeChild(el); } }); </code></pre> <h2>Calling methods on ViewModel from events within the template</h2> <p>Using html attributes like <code>can-EVENT-METHOD</code>, you can directly call a ViewModel method from a template. For example, we can make <code>&lt;my-paginate&gt;</code> elements include a next button that calls the ViewModel's <code>next</code> method like:</p> <pre><code class="language-js">var ViewModel = DefineMap.extend({ offset: {value: 0}, limit: {value: 20}, next: function(){ this.offset = this.offset + this.limit; }, get page() { return Math.floor(this.offset / this.limit) + 1; } }); Component.extend({ tag: &quot;my-paginate&quot;, ViewModel: ViewModel, view: stache(&quot;Page {{page}} &lt;button ($click)='next()'&gt;Next&lt;/button&gt;&quot;) }); </code></pre> <p>ViewModel methods get called back with the current context, the element that you are listening to and the event that triggered the callback.</p> <div class='demo_wrapper' data-demo-src='demos/can-component/paginate_next.html'></div> <h2>Publishing events on ViewModels</h2> <p>DefineMaps can publish events on themselves. For instance, the following <code>&lt;player-edit&gt;</code> component, dispatches a <code>&quot;close&quot;</code> event when it's close method is called:</p> <pre><code class="language-js">Component.extend({ tag: &quot;player-edit&quot;, view: stache.from('player-edit-stache'), ViewModel: DefineMap.extend({ player: Player, close: function(){ this.dispatch(&quot;close&quot;); } }), leakScope: true }); </code></pre> <p>These can be listened to with <a href="can-stache-bindings.event.html" title="Response to events on elements or component ViewModels.">(event)</a> bindings like:</p> <pre><code class="language-js">&lt;player-edit (close)=&quot;removeEdit()&quot; {player}=&quot;editingPlayer&quot; /&gt; </code></pre> <p>The following demo uses this ability to create a close button that hides the player editor:</p> <div class='demo_wrapper' data-demo-src='demos/can-component/paginate_next_event.html'></div> </section> <script type="text/javascript"> var docObject = {"src":{"path":"node_modules/can-component/docs/ViewModel.md"},"description":" \nProvides or describes a constructor function that provides values and methods\nto the component's [can-component::view template]. The constructor function\nis initialized with values specified by the component element's [can-stache-bindings data bindings].\n\n","types":[{"type":"function","returns":{"types":[{"type":"Object","options":[]}],"description":"A new instance of the corresponding constructor function. This instance is\nadded to the top of the [can-view-scope] the component's [can-component::view] is rendered with.\n"},"params":[{"types":[{"type":"Object","options":[]}],"name":"properties","description":"The initial properties that are passed by the [can-stache-bindings data bindings].\n\nThe view bindings on a tag control the properties and values used to instantiate the `ViewModel`. For example, calling `<my-tag>` as follows invokes `MyTagViewModel` as shown in the following example:\n\n```\n<my-tag/> <!-- new MyTagViewModel({}) -->\n\n<my-tag\n\t{message}=\"'Hi There'\"/> <!-- new MyTagViewModel({message: \"Hi There\"}) -->\n```\n"}],"description":"A constructor function usually defined by [can-define/map/map.extend DefineMap.extend] or\n[can-map Map.extend] that will be used to create an new observable instance accessible by\nthe component's [can-component::view].\n\nFor example, every time `<my-tag>` is found, a new instance of `MyTagViewModel` will\nbe created:\n\n```js\nvar MyTagViewModel = DefineMap.extend(\"MyTagViewModel\",{\n\tmessage: \"string\"\n});\n\nComponent.extend({\n\ttag: \"my-tag\",\n\tViewModel: MyTagViewModel,\n\tview: stache(\"<h1>{{message}}</h1>\")\n})\n```\n\nUse [can-view-model] to read a component's view model instance.\n"}],"title":"ViewModel","name":"can-component.prototype.ViewModel","type":"property","parent":"can-component.prototype","_curParam":{"types":[{"type":"Object","options":[]}],"name":"properties","description":"The initial properties that are passed by the [can-stache-bindings data bindings].\n\nThe view bindings on a tag control the properties and values used to instantiate the `ViewModel`. For example, calling `<my-tag>` as follows invokes `MyTagViewModel` as shown in the following example:\n\n```\n<my-tag/> <!-- new MyTagViewModel({}) -->\n\n<my-tag\n\t{message}=\"'Hi There'\"/> <!-- new MyTagViewModel({message: \"Hi There\"}) -->\n```\n"},"_curReturn":{"types":[{"type":"Object","options":[]}],"description":"A new instance of the corresponding constructor function. This instance is\nadded to the top of the [can-view-scope] the component's [can-component::view] is rendered with.\n"},"comment":" ","pathToRoot":".."}; </script> </article> <footer><p>CanJS is part of <a href="http://donejs.com" target="_blank">DoneJS</a>. Created and maintained by the core <a href="https://donejs.com/About.html#section=section_Team" target="_blank">DoneJS team</a> and <a href="http://bitovi.com" target="_blank">Bitovi</a>. <strong>Currently 3.0.0.</strong></p></footer> </div> </div> </div> <script> steal = { instantiated: { "bundles/bit-docs-site/static.css!$css" : null } }; </script> <script type='text/javascript' data-main="bit-docs-site/static" src="./static/node_modules/steal/steal.production.js"></script> <script async defer src="https://buttons.github.io/buttons.js"></script> </body> </html>