2015-12-19 47 views
0

嗨,我需要一些幫助,我有一些重定向到我的Html網頁 林試着的一部分JSTREE找出jstree功能,可以幫助現在我有這樣的: http://pastebin.com/ZTSYXWptJSTree列表和錨

這是html代碼,它是法語:http://pastebin.com/TpLhWASp 現在發生的事情是,如果我點擊一個稱爲第1或2或3節點的節點或wtv數字,它會在節點本身重定向我,而不是href鏈接,而不是li ANY HELP?

(IM能夠做到這一點,而不與錨鏈接上的jstree點擊並將用戶在頁面上的那款,但即時通訊無法與jstree做到這一點)

這是功能,當你點擊它,它應該重定向到指定的節中的HTML頁面

$(document).ready(function() { 
$('div').eq(0).jstree(); 
$("#catTree li").on("click", "a", function() { 

    document.location.href = this; 
}); 

}); 

這是是在HTML

<body> 
    <h1>Categorie</h1> 
    <div id="catTree"> 
     <ul class="n1"> 
      <span>Liste Categorie</span> 
      <li> 
       Categorie 
       <ul class="n2"> 
        <li> 
         <a class="menu" href="#section1">Section 1</a> 
        </li> 
        <li> 
         <a class="menu" href="#section2">Section 2</a> 
        </li> 

創建我的列表的HTML代碼部分而這正是它應該是指當您單擊JStree節點上

  <header> 

      <p> 
       Nom fabricant 
      <p> 
       <a name="section1"> Section 1</a> 
     </header> 
     <br> 
     <figure> 
      <p> 
       description1 
      </p> 
      <figcaption> 
       blabla 
      </figcaption> 
      <img src="images/hat1.jpg" alt="hat"/> 
     </figure> 
     <br> 
     <footer> 
      <p> 
       Prix : 00$$ 
      </p> 
      <a href= "#section12"> Dernière section</a> 
     </footer> 

更清晰的代碼,如果你想在它的詳細信息進入的HTML引擎收錄的文件,但如果你看它有12節正是同樣的,我想那些jstree節點重定向到這些部分

+0

莫非您還請將最相關的代碼添加到問題中。 –

回答

1

這似乎爲How to get I get leaf nodes in jstree to open their hyperlink

檢查DUP http://codepen.io/anon/pen/gPryPR

$('div#catTree').jstree().bind("select_node.jstree", function (e, data) { 
    var href = data.node.a_attr.href; 
    document.location.href = href; 
}); 
+0

謝謝你幫助你正確的!我只是無法格式正確的功能我想我離開了那裏的默認功能,並試圖在一個裏面的一個謝謝! – dopeinc

+0

謝謝,它也適用於我。 –