-
-
Notifications
You must be signed in to change notification settings - Fork 601
SpecAmd
Martin Wendt edited this page Nov 11, 2017
·
4 revisions
Fancytree should support AMD (require.js) and ES6 modules.
Please discuss here: https://github.com/mar10/fancytree/issues/603
- TODO
See also issue 634.
For example Page1:
// just normal fancytree
require([
'jquery',
'dist/src/jquery.fancytree'
], function($) {
//do something here
});
For example Page2:
//fancytree with menu plugin
require([
'jquery',
'dist/src/jquery.fancytree',
'dist/src/jquery.fancytree.filter'
], function($) {
//do something here
});
See also issue 603.
const jQuery = require('jquery')
//minimal required jquery-ui modules
require('jquery-ui/core')
require('jquery-ui/widget')
require('jquery-ui/effect-blind')
//import of fancytree by injecting jquery
require('imports?jQuery=jquery!jquery.fancytree/dist/jquery.fancytree.js')
//potential extensions (by injecting jquery as well)
require('imports?jQuery=jquery!jquery.fancytree/src/jquery.fancytree.childcounter.js')
//from here we can now use jQuery#fancytree
require([
'jquery',
'dist/src/jquery.fancytree'
], function($, fancytree) {
// fancytree as named module return tree api
var treeAPI = fancytree({
element: $("#tree"), // or selector: "#tree" may be ??
source: {
url: "ajax-tree-plain.json"
}
});
});
Fancytree depends on jQuery and a small subset of jQuery UI. If jQuery UI is already part of the project, Fancytree will nicely integrate:
<link href="../src/skin-win8/ui.fancytree.css" rel="stylesheet">
<script src="../lib/jquery.js"></script>
<script src="../lib/jquery-ui.custom.js"></script>
<script src="../src/jquery.fancytree-all.js"></script>
But we don't need to pull in jQuery UI explicitly, just for Fancytree. Use the complete build instead:
<link href="../src/skin-win8/ui.fancytree.css" rel="stylesheet">
<script src="../lib/jquery.js"></script>
<script src="../src/jquery.fancytree-all-deps.js"></script>
<link href="../src/skin-win8/ui.fancytree.css" rel="stylesheet">
<script src="../lib/jquery.js"></script>
<script src="../lib/jquery-ui.custom.js"></script>
<script src="../src/jquery.fancytree.js"></script>
<script src="../src/jquery.fancytree-filter.js"></script>
See also issue 694.
Documentation Home - Project Page - Copyright (c) 2008-2022, Martin Wendt (https://wwWendt.de)