webanimals / dynatree

Automatically exported from code.google.com/p/dynatree
0 stars 0 forks source link

Adding a class to the title breaks using onClick function that checks if title was clicked #421

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I'm using dynatree 1.2.4, and add a class to some titles onRender so I can 
differentiate them visually, ie 

    if(node.data.my_folder !== true) {
          $(nodeSpan).find('.dynatree-title').addClass('not-mine');
    };

This, however, breaks my onClick function and prevents it from firing: 

           onClick: function(node, event) {
                if(node.getEventTargetType(event) === "title"){
                   //change another pane in the page, do some other stuff
                };

It turns out that under the covers, node.getEventTargetType is checking to see 
if the class name is === this.tree.options.classNames, which only contains the 
original "dynatree-title" class.  Thus node.getEventTargetType returns false, 
when in fact i am clicking on the title.  My patch looks at whether string 
dynatree-title is contained in the set of classes.  I wanted to check if there 
was a better/faster way to do this though, or alternative supported method.

Here is the original code from the function getEventTargetType, followed by my 
patch:

original:
         if( tcn === cns.title ){
            return "title";
         };

patch:
        if( tcn.indexOf(cns.title ) !== -1 ) {
            return "title";
        };

Original issue reported on code.google.com by john.a.s...@gmail.com on 22 Apr 2013 at 4:18

GoogleCodeExporter commented 9 years ago
thanks!

Original comment by moo...@wwwendt.de on 22 Apr 2013 at 6:44

GoogleCodeExporter commented 9 years ago

Original comment by moo...@wwwendt.de on 8 Sep 2013 at 7:32