问题
How did they accomplish this function in the theme, where you click on the permalink (eyeball) button the uri changes, with out a hash (#) How is this done? is it ajax? or something else.
I assume it's calling the page but no reload?
theme: http://thingslog-theme.tumblr.com/ (click the eyeball at the bottom of each post)
I'm stumped and help?
回答1:
They use a code of this kind :
$('a').click(function() {
link = $(this).attr('href')
history.pushState({}, '', link);
$('#content').load('/content.php?url='+link)
return false;
})
with the history pushstate function which allow you to add and modify the browser history entries.
回答2:
We use Backbone + HTML5 pushState to handle the URI changes without the hash. It's works because we follow how Tumblr structures their URLs for all blogs.
We use jQuery.load to handle fetching the html and loading it into the page.
That code looks somewhat like this:
$container.load('http://blog.tumblr.com/post/123 #container', function() {
var $post = that.$('.overlay-container .post');
that.view = new App.PostViewFactory.createView($post);
that.view.on('close', function() {
window.history.back();
});
});
Hope that helps.
来源:https://stackoverflow.com/questions/17776567/uri-changes-without-reload