Skip to content

Commit e1b0fb9

Browse files
committed
merged with ckald
1 parent 7144eed commit e1b0fb9

File tree

1 file changed

+30
-4
lines changed

1 file changed

+30
-4
lines changed

README.md

+30-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
## pushState + ajax / hash navigation + ajax / hash navigation + ajax + form ajax + get forms parameters in address = pjax with normal fallback!
1+
# pjax with normal fallback!
2+
## pushState, hash-navigation, ajax forms, interchangeable url formats and other remarkable features
23

34
.--.
45
/ \
@@ -27,7 +28,7 @@ I hope, you'll enjoy mix of pushState and regular #!/hash navigation.
2728

2829
Some features and changes:
2930

30-
* IE 7,8 support (maybe some others)
31+
* IE7+, FF4+ and all modern browsers (if it works on some not mentioned ancient browser – please let me know `[email protected]`)
3132
* mix of html5-like navigation and old-school #!/hashes
3233
* i added most of ';' in lines of code for you :]. for some reason, defunkt didn't use them, but it was strange for me
3334
* links from both kinds of browsers are interchangable
@@ -37,10 +38,27 @@ Some bad news:
3738
* you HAVE to put some settings before using:
3839

3940
```js
40-
$.siteurl = 'http://yousite.com';
41+
$.hash = '#!/';
42+
$.siteurl = 'http://yoursite.com';
4143
$.container = '#pjaxcontainer';
4244
```
4345

46+
`$.hash` is a string, which appeares is url, when browser doesn't support pushState. So, by default, url of page changes from http://yoursite.com/this/is/awesome/article to http://yoursite.com/#!/this/is/awesome/article and pjax sends request to server with first url.
47+
48+
Links are interchangable – so if someone with modern browser gets old-style link http://yoursite.com/#!/page – he would be redirected to http://yoursite.com/page and vice versa.
49+
50+
## And what about SEO?
51+
52+
All we know, most part of AJAX-enabled sites have issues with search engine crawlers – their links are basically not parsable because of `#`. But we can handle it at least with Google!
53+
54+
Default `$.hash` value is meaningful and hopely would be parsed in future by all major search engine crawlers. All you need – set up some custom routing on your server: if crawler meets link like http://yoursite.com/#!/some/path/on/site, he sends request to http://yoursite.com/?_escaped_fragment_=/some/path/on/site and parses it.
55+
56+
For more information:
57+
58+
* http://googlewebmastercentral.blogspot.com/2009/10/proposal-for-making-ajax-crawlable.html
59+
* http://code.google.com/intl/ru-RU/web/ajaxcrawling/docs/specification.html
60+
61+
4462
## What was it?
4563

4664
Pjax loads HTML from your server into the current page
@@ -190,6 +208,14 @@ def my_page
190208
end
191209
```
192210

211+
One more Rails example by slayerhabr (http://slayerhabr.habrahabr.ru/)
212+
213+
```ruby
214+
class ApplicationController < ActionController::Base
215+
layout Proc.new { |controller| request.headers['X-PJAX'] ? false : 'application' }
216+
end
217+
```
218+
193219
Django: <https://github.com/jacobian/django-pjax>
194220

195221
Asp.Net MVC3: <http://biasecurities.com/blog/2011/using-pjax-with-asp-net-mvc3/>
@@ -252,4 +278,4 @@ Then, in your HTML:
252278
```
253279

254280
Replace `path/to/js` with the path to your JavaScript directory,
255-
e.g. `public/javascripts`.
281+
e.g. `public/javascripts`.

0 commit comments

Comments
 (0)