Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pjax form submit heroku example #489

Open
wants to merge 11 commits into
base: heroku
Choose a base branch
from
6 changes: 6 additions & 0 deletions app/views/index.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
<li><a href="/aliens.html">aliens</a></li>
</ul>

<h1><%= params[:text] %></h1>
<form method="GET">
<input type="text" name="text">
<input type="submit">
</form>

<p>
pjax loads html from your server into the current page
without a full page load. It's ajax with real permalinks,
Expand Down
9 changes: 5 additions & 4 deletions app/views/layout.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,16 @@
<%# finally, make the page-top bar somewhat respectably toned down too %>
<meta name="apple-mobile-web-app-status-bar-style" content="black">

<script src="jquery.js"></script>
<script src="jquery.cookie.js"></script>
<script src="//code.jquery.com/jquery-1.11.2.js"></script>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 from loading from CDN. You may remove the old vendored jquery.js and references to it.

<script src="pages.js"></script>

<script src="jquery.pjax.js"></script>
<script type="text/javascript">
$(function(){
// pjax
$('ul a').pjax('#main')
$(document).pjax('ul a', '#main')
$(document).on('submit', 'form', function(e) {
$.pjax.submit(e, '#main')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you change the invocation? I preferred the shorter form. It works good as a demo.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's legacy API. With the version of jquery I updated, live doesn't seems to work anymore.
https://github.com/defunkt/jquery-pjax#legacy-api

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah OK, got it. The new invocation you wrote looks good.

});
})
</script>

Expand Down
1 change: 0 additions & 1 deletion jquery.cookie.js

This file was deleted.

16 changes: 0 additions & 16 deletions jquery.js

This file was deleted.

Loading