Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>EDIT** the below answer is for durandal 1.2. In durandal 2.0 <code>viewAttached</code> has changed to <code>attached</code></p> <hr> <p>Copy pasted directly from durandaljs.com</p> <p>"Whenever Durandal composes, it also checks your model for a function called <code>viewAttached</code>. If it is present, it will call the function and pass the bound view as a parameter. This allows a controller or presenter to have direct access to the dom sub-tree to which it is bound at a point in time after it is injected into its parent.</p> <p>Note: If you have set <code>cacheViews:true</code> then <code>viewAttached</code> will only be called the first time the view is shown, on the initial bind, since technically the view is only attached once. If you wish to override this behavior, then set <code>alwaysAttachView:true</code> on your composition binding." --<a href="http://durandaljs.com/documentation/Composition/" rel="nofollow">quoted from the site</a></p> <hr> <p>There are many ways you can do it but here is just 1 quick and dirty way:</p> <pre><code>&lt;section&gt; &lt;h2 data-bind="html: displayName"&gt;&lt;/h2&gt; &lt;h3 data-bind="html: posts"&gt;&lt;/h3&gt; &lt;button data-bind="click: getRss"&gt;Get Posts&lt;/button&gt; &lt;div id="rsstestid"&gt;&lt;/div&gt; &lt;/section&gt; </code></pre> <p>and the code:</p> <pre><code>define(function (require) { var http = require('durandal/http'), app = require('durandal/app'); var $rsstest; return { displayName: 'This is my RssTest', posts: ko.observable(), viewAttached: function(view) { $rssTest = $(view).find('#rsstestid'); }, getRss: function() { $rssTest.rssfeed('http://feeds.reuters.com/reuters/oddlyEnoughNews'); } }; }); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload