I am building a website using the sammy.js framework. I have a sidebar that is constant, and the main content view which loads the different pages with the help of sammy. On the side bar I have links to news articles. Currently any of the article links on the sidebar just load the #/news route. But I'd like it load the route and scroll down to the article. I've tried having an anchor link trigger once the route is loaded to scroll down to the article, but I get errors with the sammy app. Any thoughts on how this could be accomplished?
相关问题
- How to fix IE ClearType + jQuery opacity problem i
- jQuery add and remove delay
- Include empty value fields in jQuery .serialize()
- Disable Browser onUnload on certain links?
- how to get selected text from iframe with javascri
Seems like an old question but since it's still unanswered....
You have to define your URL as a regular expression, and allow an optional bookmark hash at the end of it:
This will match any of the following routes:
You should then be able to use the articleId to find the matching element and manually scroll. e.g. in the last route above, 'articleId' will be '#my-news-article', so using jQuery you could do something like:
Hope that helps.