javascript error "is not a function..." but libraries are loaded
<p>I'm trying to use fancytree in a Durandal page.  I've done this before but I can't seem to get this working now and it's driving me mad.</p>

<p>I have a js debug stop point on the <code>$("#tree").fancytree...</code> line and at the point the code stops, I have the following three libraries loaded:</p>

<pre><code>jquery-1.12.1.js    
jquery-ui-1.11.4.js 
jquery.fancytree.js 
</code></pre>

<p>And yet there is no "fancytree" prototype method showing for the element and I get <code>system.js:109 TypeError: $(...).fancytree is not a function(…)</code> on the initialization line.  In the past this has been caused by a lacking jquery-ui library, but clearly that is loaded here.</p>

<p>What am I missing please?</p>

<p>Edited to add more information.</p>

<p>HTML is largely irrelevant as it just has</p>

<pre><code>&lt;div id="tree"&gt;&lt;/div&gt;
</code></pre>

<p>There is an attached viewmodel which contains:</p>

<pre><code>    self.attached = function (vw, prt) {
        buildTree(vw);
    }
</code></pre>

<p>and</p>

<pre><code>    function buildTree(view) {
        // Initialize Fancytree
        $("#tree").fancytree({
            checkbox: true,
            selectMode: 2,
            source: {url: "testdata/ajax-tree-taxonomy.json", debugDelay: 1000},
            toggleEffect: { effect: "drop", options: {direction: "left"}, duration: 400 },
            lazyLoad: function(event, data) {
                data.result = {url: "testdata/ajax-sub2.json", debugDelay: 1000};
            }
        });

    }
</code></pre>

<p>I put my debug stop point at the <code>$("#tree").fancytree({</code> line and by then it has loaded the libraries mentioned above.</p>

<p>Edit 2:
Curiouser and curiouser... I've been doing more debugging.  I put a stop point inside of the jquery.fancytree.js library and the code execution gets in there!  What's more, it actually creates the element.fancytree method needed and that stays attached to the element for a long while during debugging. Trouble is, something then happens later in the jquery initialization that REMOVES the .fancytree() method from the element and before the code execution gets back out of the jquery library!  </p>

<p>I have another test html page that loads the exact same jquery, jquery-ui and jquery.fancytree libraries and that works just fine. It must surely be something to do with Durandal then?</p>