npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

js-tree-bind

v0.0.1

Published

A jQuery plugin that allows the use of data binding frameworks (Angular, Ember, Knockout etc.) with the jsTree UI component.

Readme

jsTree Bind

A jQuery plugin that allows the use of data binding frameworks (Angular, Ember, Knockout etc.) with the jsTree UI component.

Rationale

jsTree is a fantastic plugin, but it's a bit behind the times. Unlike when it was first designed, web apps are now based on data binding rather than raw DOM manipulation. However using jsTree with a databinding framework has two main problems:

  • jsTree is designed for static data; data that never changes once it's been set.
  • You have to mangle your data into jsTree's specific JSON format in order for it to be displayed

My solution to these problems is to use the native capability of every framework; to bind data to the DOM. jsTree Bind uses the DOM as a template from which to create nodes, allowing you to have data in any structure, structure it in any way, but still present it in a tree format using jsTree

Installation

Just run npm install js-tree-bind or git clone https://github.com/TMiguelT/jsTreeBind to get a copy of the repository, then copy either jsTreeBind.js or jsTreeBind.min.js somewhere into your project.

Usage

To use jsTree Bind, all you need to do is call $("#js-tree").jsTreeBind("#tree-template");

The first element (#js-tree in this case) is the element that will receive the new tree. It's the element that will actually be shown.

The second element, #tree-template, is the DOM element to be used as the template for the tree.

Directly inside the #tree-template element should be one or more HTML elements, which will serve as the root nodes for the tree. These elements, and any child nodes nested further in the tree are used to generate jsTree nodes using the following rules:

  • Text directly inside a node will be merged into that the jsTree node's text

  • Nested elements will be used to generate child nodes

  • As in the jsTree docs, the data-jstree attribute can be used on any element to to provide a json object to use as the node's data

  • Any other data-* attributes can be used on the HTML elements, which work as you'd expect (e.g. data-icon sets the node's icon class or image URL, data-disabled disables the node etc.)

Read on for an example!

Example

<!--Set the template element to be hidden so it doesn't show up in the DOM-->
<div class="hidden" id="tree-template">

    <!--The root node that has the text 'People'-->
    <div>
        People
        <div ng-repeat="person in people()">

            <!--Using a text node to set the text property-->
            {{ person.name }}

            <!--Using a data-attribute to set the text property-->
            <div data-text="Tags">
                <!--Using a data-attribute to set the icon property-->
                <div data-icon="glyphicon glyphicon-leaf" ng-repeat="tag in person.tags track by $index">{{tag}}</div>
            </div>

            <div data-text="Friends">

                <!--Using data-jstree to disable the node (the only way to set boolean properties afaik-->
                <div data-jstree='{"disabled": true}' data-icon="glyphicon glyphicon-leaf"
                     ng-repeat="friend in person.friends">{{friend.name}}
                </div>
            </div>

            <div data-text="Age">
                <!--Using a data-jstree attribute to set the icon-->
                <div data-jstree='{"icon": "glyphicon glyphicon-leaf"}'>{{person.age}}</div>
            </div>

            <div data-text="Gender">
                <!--Using data-attribute to disable the node-->
                <div data-disabled="true" data-icon="glyphicon glyphicon-leaf">{{person.gender}}</div>
            </div>
        </div>
    </div>
</div>

<!--The element that will recieve the jsTree-->
<div id="js-tree"></div>

Example

For more detail on this example, including the Angular $scope data, and sample usage for another framework (VueJS), have a look in the /demo directory of the repository.