Home > Net >  navbar active link not working with real link
navbar active link not working with real link

Time:07-19

I have been tried all day to make the link active when I click on it but it only works with a href that is "fake" but not with my href. In the example code, it works for Research but not for Upload.

<li >
  <a  href="{{ url_for('uploader.upload') }}">Upload</a>
</li>
<li >
  <a  href="#">Research</a>
</li>

CodePudding user response:

I think that you'll have to paste the link without the brackets:

<li >
  <a  href="https://stackoverflow.com">Upload</a>
</li>
<li >
  <a  href="#">Research</a>
</li>

Or if you have a file or a document that you want to display/execute:

<li >
  <a  href="MainFolder/file.extension">Upload</a>
</li>
<li >
  <a  href="#">Research</a>
</li>

I hope this helped you.

CodePudding user response:

ended up working, turned out jquery and bootstrap were not in sync

<nav >
<a  href="{{ url_for('main.index') }}">Hazen</a>
<button  type="button" data-toggle="collapse" 
data-target="#navbarNavAltMarkup" aria-controls="navbarNavAltMarkup" 
aria-expanded="false" aria-label="Toggle navigation">
<span ></span>
</button>
<div  id="navbarNavAltMarkup">
<div >
{% if not current_user.is_anonymous %}

<a   href="{{ url_for('main.user', 
username=current_user.username) }}">Dashboard</a>
<a  href="{{ url_for('uploader.upload') }}">Upload</a>
{% endif %}
{% if current_user.is_anonymous %}

<a   href="{{ url_for('auth.login') 
}}">Login</a>

{% else %}

<a   href="{{ url_for('auth.logout') 
}}">Logout</a>

{% endif %}
</div>
</div>
</nav>
  • Related