I'm using durandal to make a SPA website. Thing is, the URL not not stable everytime.
I make the login page outsite of SPA, so after login, I use RedirectToAction
of MVC3 to redirect to SPA index.
Sometimes the URL is http://localhost/Student/Home/Index#/
while sometimes it's http://localhost/Student/Home/Index/#/
At first I think this is not a big deal, but right now this really pissed me off because I have to use images outside of durandal folder.
- durandal folder
- Content/Images folder
When I call from a SPA view like this:
<img src="../Content/Images/img_chart.png" alt=""/>
I only work when the URL is Index#/
not when the URL is Index/#/
How can I make a URL stable everytime? This seem to be a problem of SammyJS I suppose.
Apply the image src via a class defined in a css file. Once you do that, you can use the image location relative to your css location.
<div><img class="loading" /></div>
the class for "loading" can be defined in your base css. I have it defined in my layout.css
.loading
{
content:url('images/ajax-loader.gif');
}
Now, the layout.css mentioned uses its own location to form the relative path to the images folder and it all works.
|-[]Images
|-ajax-loader.gif
|-[]SomeotherFolder
|-layout.css
hope this helps