Dynatree and qtip2 — No (hover) events on first su

2019-07-29 03:52发布

问题:

I have a custom qtip that I want to show when you hover the mouse over a node in my Dynatree.

The problem I'm having is that I do not seem to be getting any subnode hover events on the first child of a parent.

I'm creating children like this:

var tipKey = uuid();
var childNode = parent.addChild({
            title: field.Description,
            isFolder: false,
            icon: icon,
            key: tipKey,
            addClass: tipKey,
        });
        $("." + tipKey).qtip({
            content: {
                text: '   ',
                title: {
                    text: '   '
                }
            },
            style: {
                classes: 'ui-tooltip-shadow ui-tooltip-yellow'
            },
            events: {
                show: function (event, api) {
                    var node = $.ui.dynatree.getNode($(api.elements.target));
                    var field = _workingFieldList[node.data.key];
                    //code to set qtip content omitted.
                }
            }
        });

All the tips appear just fine except the 1st child of every parent. This is either a bug, or, some strange issue I'm not seeing. If I add a handler for $('#tree a').hover(), I do get the events on every mousein/out; I tried to use that to show the qtip, but that did not work either.

回答1:

Dynatree renders nodes only when expanded for the first time, so your code may bind too early. Try to bind in the 'onCreate' callback instead.