0

I'm trying to apply a css class to a navigation bar panel if the current page URL is the URL of what the panel points to.

<div class="panel panel-default" 
     data-bind="css: {'test-class': window.location === My.Constants.appRoot 
                                    + '/thispage'}">

This binding doesn't seem to work. Anyone have ideas on whether or not this should work? Thanks!

1
  • 1
    Any errors in the console? It's hard to say what's wrong without more information. Commented Jul 8, 2014 at 16:29

1 Answer 1

1

You need to use window.location.href.

http://jsfiddle.net/zTK2q/2/

Sign up to request clarification or add additional context in comments.

1 Comment

As a note if you are updating the class based on the URL but are only using hash routing or something this will not be notified

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.