2014-12-06 49 views
1

我试着实现引导标签和内部标签BOOTSTRAP COLLAPSE。如何在同一时间实现引导选项卡和折叠菜单?

制表符,我实现:

<script type="text/javascript"> 
$(document).ready(function() 
{ 
//Redirecciona al tab, usando un prefijo al cargar por primera vez, al usar redirect en cake #_Pagos  
//Redirecciona al tab, usando #Pagos 
/* Automagically jump on good tab based on anchor; for page reloads or links */ 
if(location.hash) 
    { 
    $('a[href=' + location.hash + ']').tab('show');   
    } 


//Para evitar el bajar al nivel del tab, (al mostrarse el tab subimos) 
$('a[data-toggle="tab"]').on('shown.bs.tab', function(e) 
{ 
    location.hash = $(e.target).attr('href').substr(1); 
    scrollTo(0,0);  
}); 



//Actualiza el URL con el anchor o ancla del tab al darle clic 
/* Update hash based on tab, basically restores browser default behavior to 
fix bootstrap tabs */ 
$(document.body).on("click", "a[data-toggle]", function(event) 
    { 
    location.hash = this.getAttribute("href"); 
    }); 


//Redirecciona al tab, al usar los botones de regresar y avanzar del navegador. 
/* on history back activate the tab of the location hash if exists or the default tab if no hash exists */ 
$(window).on('popstate', function() 
{ 
    //Si se accesa al menu, se regresa al tab del perfil (activo default), fixed conflict with menu 
    //var anchor = location.hash || $("a[data-toggle=tab]").first().attr("href"); 
    var anchor = location.hash; 
    $('a[href=' + anchor + ']').tab('show'); 

}); 

});//Fin OnReady 
</script> 

,但每当我点击崩溃,页面滚动起来。无论如何,我可以有效地使用两者。

这是链接:http://custmr.co.uk/industry-specific/

我们点击“不动产”后,我们就可以去崩溃。

在此先感谢

回答

0

您错过了防止“锚”默认事件;

例:

$(document.body).on("click", "a[data-toggle]", function(event){ 
    event.preventDefault(); 
    location.hash = this.getAttribute("href"); 
    }); 

FYI

http://api.jquery.com/event.preventdefault/

“事件单击” 锚元素默认调用诸如<a href="#">some foo</a>

没有本质POR阙罗escribí连接在同一个页面英语西班牙语和德语西班牙语西班牙语。

+0

谢谢,我实现了preventDefault,但仍然是同样的问题。你知道我必须在哪里纠正?对西班牙语评论抱歉,我从一些论坛找到了代码。 – 2014-12-12 14:08:09