All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.jwebmp.plugins.jstree.events.onselectedevent.JSTreeOnSelectDirective.js Maven / Gradle / Ivy

There is a newer version: 1.2.2.1-jre17
Show newest version
JW_APP_NAME.directive('ngJstreeOnSelect', function ($parse) {
    return function (scope, element, attrs) {
        var fn = $parse(attrs.ngJstreeOnSelect);
        element.on('select_node.jstree', function (event, data) {
            scope.$apply(function () {
                event.preventDefault();
                if (event.data === undefined) {
                    event.data = {};
                }

                var eventData = {};
                event.data.selected = data.node;

                eventData.parents = data.node.parents;
                eventData.children = data.node.children;
                eventData.children_d = data.node.children_d;
                eventData.li_attr = data.node.li_attr;
                eventData.a_attr = data.node.a_attr;
                eventData.state = data.node.state;
                eventData.text = data.node.text;

                event.data.selected = eventData;

                var id = event.currentTarget.id;

                event.currentTarget = {};
                event.currentTarget.id = id;

                event.delegateTarget = undefined;

                id = event.target.id;
                event.target = {};
                event.target.id = id;
                event.type = 'selected';
                var exec = 'jw.' + attrs.ngJstreeOnSelect;
                var $event = event;
                $event.data = JSON.stringify($event.data);
                eval(exec);
                $event = undefined;
            });
        });
    };
});




© 2015 - 2025 Weber Informatics LLC | Privacy Policy