github上如导航 [英] github like navigation

查看:155
本文介绍了github上如导航的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
  <一href="http://stackoverflow.com/questions/7591087/how-does-github-change-url-without-reloading-a-page">How确实github上改变URL,而不重新加载页面?


我不知道该怎么形容,但如何做GitHub上的文件浏览器工作这凉爽的幻灯片效果?
不是图形化的一部分,但背后的JavaScript / AJAX逻辑。这似乎是页面未重载以及下一个目录只是幻灯片。我认为用JavaScript你只能改变散,而不是URL的完整路径。
那么,怎么可能从somedomain.com/foo更改URL无需重新加载整个页面,只需加载通过AJAX或WebSockets的新内容somedomain.com/foo/bar~~V。我definitly不知道如何做到这一点,或与招这部作品在github上。


I don't know how to describe but how does this cool slide effect on github file explorer work?
Not the graphical part but the javascript/ajax logic behind. It seems like the page isn't reloading and the next directory just slides in. I thought that with javascript you only can change the hash, not the whole path of the url.
So, how is it possible to change the url from somedomain.com/foo to somedomain.com/foo/bar without reloading the whole page, just loading the new content via ajax or websockets. I definitly don't know how to do this, or with which trick this works on github.

推荐答案

您可以使用JavaScript库这种事情。一个好的是History.js。它采用推状态时,它可以和回落到哈希爆炸URL时没有。我用它的几个项目,发现它真的很不错,特别是如果你使用的js模板为好。如Dust.js

You can use javascript libraries for this kind of thing. A good one is History.js. It uses push state when it can and falls back to hash bang urls when not. I've used it in a couple of projects and find it really good especially if you use js templates as well. Such as Dust.js

下面是一个链接Historyjs GitHub的网页。历史JS

Here is a link to the Historyjs github page history js.

至于阿贾克斯去。我用我的网址类型标识符。因此,当用户浏览到/ home,也没有重新加载页面,而是一个Ajax调用被分派到/homepage.json 从其中一个JSON响应检索,然后渲染到DOM或JS模板。

As far as the ajax goes. I used a type identifier on my url. So when a user navigates to /home, there is no page reload and instead an ajax call is dispatched to /homepage.json From which a json response is retrieved and then rendered into the dom or the js template.

这篇关于github上如导航的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆