[英]twitter bootstrap dropdown not working in django template
感謝您嘗試提前提供幫助!
我的問題是,twitter bootstrap的下拉菜單(對於navbar)對我不起作用,我現在很迷路。 我的標頭代碼(所以,是的,我確實包含了他們的.js並稱之為):
<head>
<title>{% block title %}User test{% endblock %}</title>
<!--for IE6-8 support of HTML elements -->
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<script type="text/javascript" src="http://twitter.github.com/bootstrap/assets/js/bootstrap-dropdown.js"></script><!--dropdown addon-->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script><!--jquery-->
<script type="text/javascript">
$(document).ready(function(){
$('.dropdown-toggle').dropdown();
});
</script>
<link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}style.css" /><!--link to my style.css-->
<link rel="stylesheet" type="text/css" href="http://twitter.github.com/bootstrap/assets/css/bootstrap.css" /><!--link to bootstrap's css-->
可能具有下拉菜單的菜單項:
<ul class="nav">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
{% trans "Logged in" %}: {{ user.username }}
<b class="caret"></b>
</a>
<ul class="dropdown-menu">
<li><a href="{% url auth_password_change %}">{% trans "Change password" %}</a></li>
<li><a href="{% url auth_logout %}">{% trans "Log out" %}</a></li>
</ul>
</li>
<li><a href="/upload/">{{ "Upload your CVS" }}</a></li>
<li><a href="/settings/">{% trans "Settings" %}</a></li>
</ul>
再次感謝,
布拉吉布拉
切換您的js包含的順序,以便首先加載jQuery。
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script><!--jquery-->
<script type="text/javascript" src="http://twitter.github.com/bootstrap/assets/js/bootstrap-dropdown.js"></script><!--dropdown addon-->
您必須使用最新版本的jquery(1.7)
正如約翰所說,我確實需要改變思路。 由於某些神奇的原因(仍然不知道為什么!),它在甚至沒有設置的斷點處中斷,因此沒有加載jquery。 重新啟動瀏覽器后,它可以工作了。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.