Comments (7)
I decided on that because it's important to have the language in the URL. That is, if you're looking at the Ruby tab, you should be able to copy the URL and have it automatically point to the Ruby tab.
There's a way to change the URL with pushstate
and popstate
, but I couldn't figure out how to make it work well with the back button and tocify, so that the back button properly sends you to the correct position in the ToC. If you can figure out a way, I'd be glad to accept a pull request!
from slate.
Ah, and there was one other reason I chose to reload the page — it ensures when you switch languages, you stay in the same section. A good implementation pushstate
should make sure that if the user switching tab while in a section, they remain in that section, even if the code samples above them are of different lengths. Maybe I can look into this in a couple weeks, I agree, reloading the page isn't optimal.
from slate.
This seems to work:
// if we click on a language tab, activate that language
$("#lang-selector a").bind("click", function() {
var lang = $(this).data("language-name");
var hash = window.location.hash;
if (hash) hash = hash.replace(/^#+/, '');
// do not reload the page every time the language is changed
if (history) history.pushState({}, '', '?' + lang + '#' + hash);
activateLanguage(lang);
return false;
});
from slate.
I'll take a look at this over the weekend, thanks!
from slate.
Ah, nice! It works for me, although I needed to add a onpopstate
to handle users pressing history buttons. Thanks.
from slate.
Awesome. Thanks for fixing this.
from slate.
No problem. Let me know if you run into any issues with it, I haven't tested it super extensively.
from slate.
Related Issues (20)
- Code error HOT 1
- Heroku deployment
- Success redirect
- EMFILE, possible file handler leak
- Difficulty implementing on Windows machine HOT 1
- Difficulty implementing on Windows machine in both approach (ruby & docker as well) HOT 3
- Search function not finding results HOT 2
- [email protected]
- lang specific blockquotes weird behavior. HOT 2
- no implicit conversion of Hash into Integer HOT 1
- bundle exec middleman server: have error
- diff ruby version HOT 1
- Build with Docker should create a build folder with current owner user instead of root HOT 3
- unable to configure the slate set up in windows HOT 1
- UniqueHeadCounter not working when deploying with Docker HOT 1
- Update Invoice API documentation HOT 2
- editable re-render cause the cursor to be brought forward in composing events.
- ddd
- i got /usr/bin/env: ‘bash\r’: No such file or directory when i run the container
- Incorrect Section Highlighted in TOC When Near End Of Page
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from slate.