2

I have a link on web page

<li data="url: 'www.mypage.com?index.php?CId=2&MId=14&MTId=1'">mylink

In my js script I have

$(document).ready(function() {

 $("#tree").dynatree({
 persist: true,

 onPostInit: function(isReloading, isError) {
        this.reactivate();
 },

 onActivate: function(dtnode) {
        var isInitializing = dtnode.tree.isInitializing(); 
        var isReloading = dtnode.tree.isReloading(); 
        var isUserEvent = dtnode.tree.isUserEvent(); 

       if( dtnode.data.url )
          window.open(dtnode.data.url); 

}   

    });

});

What should I do instead of window.open so the url reloads in the same window, not opening a new one? There's no name in the web page where I could use iFrame way.

mar10
  • 11,918
  • 5
  • 35
  • 58
chz
  • 319
  • 1
  • 7
  • 17
  • Maybe this answers your question: http://stackoverflow.com/questions/6070484/how-to-make-hyperlinks-in-dynatree-jquery-plugin-clickable/6086484#6086484 – mar10 Sep 10 '11 at 08:56

4 Answers4

3

I would suggest

onActivate: function(node) { 
    if( node.data.href ){
        // use href to change the current frame:
        window.location.href = node.data.href; 
        // or load data into a div tag:
//      $("#div").load(node.data.href);
        // or open href in another target frame:
//      window.open(node.data.href, node.data.target);
    }
}

See also here for another example: How to make hyperlinks in dynaTree jQuery plugin clickable?

Community
  • 1
  • 1
mar10
  • 11,918
  • 5
  • 35
  • 58
2

dynatree now allows you to put anchor tags in the li elements. So you can simply do:

<li><a href="www.mypage.com\index.php?CId=2&MId=14&MTId=1" target="_top">mylink</a>

Take a look at the navigation examples here.

Matt Penner
  • 988
  • 9
  • 21
0

This is the documented way:

onActivate: function(node) {
   if( node.data.href ) {
      window.open(node.data.href, node.data.target);
      return false;
   }
},
Comstar
  • 1,206
  • 11
  • 8
0

have you tried this solution:

$(document).ready(function() {

   $("#tree").dynatree({ persist: true,

      onPostInit: function(isReloading, isError) { this.reactivate(); },

      onActivate: function(dtnode) { 
         var isInitializing = dtnode.tree.isInitializing(); 
         var isReloading = dtnode.tree.isReloading(); 
         var isUserEvent = dtnode.tree.isUserEvent();

         if( dtnode.data.url )
            window.location.href = dtnode.data.url; 
      }
   });
});
Falle1234
  • 4,876
  • 1
  • 20
  • 29
  • Hi Felle I would love to hear from you of an answer of another side-effect issue below. – chz Aug 03 '10 at 01:49
  • Hi Felle When I execute with Dynatree, I saw the html content it generated The html file shows – chz Aug 03 '10 at 08:01
  • Retry In my current front.tpl file, ===================
  • {$obj->mCMType[k].name}
  • {$obj->mCMType[k].name2}
  • {$obj->mCMType[k].name3}
  • {$obj->mCMType[k].name4} When clicking on any of the above, hovering my mouse over them show. http://localhost/people/#. After clicking and page reloads, the right screen shows correct input.
  • – chz Aug 03 '10 at 08:11
  • But the dyna tree parents folders all expand to show document nodes or all collasped showing only folders. Before dynatree was ever used, it was like this where the href contains the whole url string.
  • {$obj->mCMType[k].name}
  • So on clicking the link, the http request contains the whole string like this: http://localhost/people/index.php?cid=1&tid=5&vid=3 I also double checked the of the file, there's nothing wrong there. – chz Aug 03 '10 at 08:11
  • For sure we need url: '{$obj->mCType[k].link_to_type} Is there a way to replace # with actual url string inside using dyna rules ?
  • {$obj- >mCMType[k].name but do I pass another parameter to replace # of href of ui-dynatree- title ?
  • – chz Aug 03 '10 at 08:13