jquery - javascript error "is not a function..." but libraries are loaded -
i'm trying use fancytree in durandal page. i've done before can't seem working , it's driving me mad.
i have js debug stop point on $("#tree").fancytree...
line , @ point code stops, have following 3 libraries loaded:
jquery-1.12.1.js jquery-ui-1.11.4.js jquery.fancytree.js
and yet there no "fancytree" prototype method showing element , system.js:109 typeerror: $(...).fancytree not function(…)
on initialization line. in past has been caused lacking jquery-ui library, loaded here.
what missing please?
edited add more information.
html largely irrelevant has
<div id="tree"></div>
there attached viewmodel contains:
self.attached = function (vw, prt) { buildtree(vw); }
and
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}; } }); }
i put debug stop point @ $("#tree").fancytree({
line , has loaded libraries mentioned above.
edit 2: curiouser , curiouser... i've been doing more debugging. put stop point inside of jquery.fancytree.js library , code execution gets in there! what's more, creates element.fancytree method needed , stays attached element long while during debugging. trouble is, happens later in jquery initialization removes .fancytree() method element , before code execution gets out of jquery library!
i have test html page loads exact same jquery, jquery-ui , jquery.fancytree libraries , works fine. must surely durandal then?
fixed it! requirejs reloading jquery. found answer on question: make requirejs not reload jquery if on page
i added:
define('jquery', [], function () { return jquery; });
...after require.js.config({...});
section , before define(['knockout', 'durandal/system', ... {
section.
can't believe simple...
Comments
Post a Comment