[Fixed]-Jquery make tab active from another page

1👍

You are setting the hash correctly on the url, But you need to run a hashChange function when you load the page to actually set the class on load. This is because when you change the url you are re initializing your application and losing any state that you are not passing back to the server with your request.

// callback to set active class based on hash
function hashChange() {
  var id = window.location.hash
  $(id).addClass('active')
}
// bind the callback to hashchange and window.onload
$(window).on('hashchange', hashChange)
$(hashChange)

// your standard click listener
$("#butonmesaj").on('click', function() {
  window.location.href = "{% url 'userena_profile_detail' user%}#messages"
});

Leave a comment