Note that there are some explanatory texts on larger screens.

plurals
  1. POLoading jquery plugin result into Durandal view
    primarykey
    data
    text
    <p>I am using the Durandal Starter Template for mvc4. I have set the following simple View:</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 ViewModel:</p> <pre><code> define(function (require) { var http = require('durandal/http'), app = require('durandal/app'); return { displayName: 'This is my RssTest', posts: ko.observable(), activate: function () { return; }, getrss: function () { $('#rsstestid').rssfeed('http://feeds.reuters.com/reuters/oddlyEnoughNews'); return; } }; }); </code></pre> <p>As you can see, it is simply using the zRssReader plugin to load posts into a div when the 'Get Posts' button is clicked. Everything works fine, the display name is populated and the posts show up as expected.</p> <p>Where I am having trouble is when I try to eliminate the button and try to load the posts at creation time. If I place the plugin call in the activate function, I get no results. I assume this is because the view is not fully loaded, so the element doesn't exist. I have two questions:</p> <ol> <li>How do I delay the execution of the plugin call until the view is fully composed?</li> <li>Even better, how do I load the plugin result into an the posts observable rather than using the query selector? I have tried many combinations but no luck</li> </ol> <p>Thanks for your help.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    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.
 

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