Я хочу сделать ссылку на родительский узел активным в виде дерева. До сих пор я это делаю:Как сделать ссылку на родительский узел активным в виде дерева?
<li><a href="beranda">A - Referensi Spasial</a> <!--this is parent node-->
<ul>
<li>Jaring Kerangka Referensi Geodesi</li>
<li>Model Geoid
<ul>
<li><a href="kugi/detail_data_kugi">AB01010010</a></li>
<li>AB01010020</li>
</ul>
</li>
<li>Stasiun Pasang Surut</li>
</ul>
</li>
Когда я нажимаю на родительский узел, он просто расширяет дочерние узлы. То, что я хочу, когда я нажимаю, он открыть ссылку я поставил на <a></a>
Вот мой снимок экрана с моей точки зрения дерева:
И это Java-код:
$.fn.extend({
treed: function (o) {
var openedClass = 'glyphicon-minus-sign';
var closedClass = 'glyphicon-plus-sign';
if (typeof o != 'undefined'){
if (typeof o.openedClass != 'undefined'){
openedClass = o.openedClass;
}
if (typeof o.closedClass != 'undefined'){
closedClass = o.closedClass;
}
};
//initialize each of the top levels
var tree = $(this);
tree.addClass("tree");
tree.find('li').has("ul").each(function() {
var branch = $(this); //li with children ul
branch.prepend("<i class='indicator glyphicon " + closedClass + "'></i>");
branch.addClass('branch');
branch.on('click', function (e) {
if (this == e.target) {
var icon = $(this).children('i:first');
icon.toggleClass(openedClass + " " + closedClass);
$(this).children().children().toggle();
}
})
branch.children().children().toggle();
});
//fire event from the dynamically added icon
tree.find('.branch .indicator').each(function(){
$(this).on('click', function() {
$(this).closest('li').click();
});
});
//fire event to open branch if the li contains an anchor instead of text
tree.find('.branch>a').each(function() {
$(this).on('click', function (e) {
$(this).closest('li').click();
e.preventDefault();
});
});
//fire event to open branch if the li contains a button instead of text
tree.find('.branch>button').each(function() {
$(this).on('click', function (e) {
$(this).closest('li').click();
e.preventDefault();
});
});
}
});
//Initialization of treeviews
$('#tree1').treed();
Итак, как я могу это сделать? Может кто-нибудь мне помочь? Спасибо
Ну, эти простые изменения оказали большое влияние. Меня устраивает. Спасибо – gultomicro
Рад, что я мог бы помочь! – ghybs