当您在URL中带有/ intent /的页面上时,仅在导航栏中需要“意图表单导航”。网址是
然后,当您导航到其他报告(例如
)时,我希望它消失我有这个工作的JS:
$(function() {
var loc = window.location.href; // returns the full URL
if(/intents/.test(loc)) {
$('.intent-nav').show();
} else {
$('.intent-nav').hide();
}
});
但是我想直接在模板中执行此操作而不使用JS,这可能吗?
侧面条形码:
{% block sidebar %}
<div class="well">
<div class="intent-nav">
<!-- Intent Form Navigation -->
<ul class="nav nav-list">
<li class="nav-header">Intent Form Navigation</li>
<li class="divider"></li>
<li><a href="{% url 'summer' %}">Summer Intent Forms</a></li>
<li><a href="{% url 'winter' %}">Winter Intent Forms</a></li>
<li><a href="{% url 'fall' %}">Fall Intent Forms</a></li>
<li><br/></li>
</ul>
</div>
<ul class="nav nav-list">
<li class="nav-header">Report Navigation</li>
<li class="divider"></li>
<li><a href="{% url 'reports' %}">Dashboard</a></li>
<li><a href="{% url 'alumni' %}">Alumni</a></li>
<li><a href="{% url 'major' %}">Major</a></li>
<li><a href="{% url 'birthday' %}">Birthdays</a></li>
<li><a href="{% url 'status' %}">Employees by Status</a></li>
<li><a href="{% url 'address' %}">Address Updated</a></li>
{% if user|in_group:"aux-dept-urec-hr-admins" or user.is_superuser %}
<li><a href="{% url 'ethnicity' %}">Employees by Ethnicity</a></li>
<li><a href="{% url 'gender' %}">Employees by Gender</a></li>
{% endif %}
<li><a href="{% url 'discipline' %}">Discipline Items</a></li>
<li><a href="{% url 'employee_discipline' %}">Employee Discipline</a></li>
<li><a href="{% url 'certifications' %}">Certifications</a></li>
<li><a href="{% url 'rewards' %}">Rewards</a></li>
<li><a href="{% url 'attendance' %}">Training Attendance</a></li>
<li><a href="{% url 'summer' %}">Intents</a></li>
</ul>
</div>
{% endblock %}