Last active
January 2, 2025 07:28
-
Star
(148)
You must be signed in to star a gist -
Fork
(78)
You must be signed in to fork a gist
-
-
Save tobysteward/6163902 to your computer and use it in GitHub Desktop.
Revisions
-
Toby Steward revised this gist
Aug 12, 2013 . 2 changed files with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -17,4 +17,4 @@ public function showPosts() return View::make('blog', array('posts' => $posts)); } } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -51,4 +51,4 @@ function getPosts(page) { </script> </body> </html> -
Toby Steward revised this gist
Aug 6, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ @foreach ($posts as $post) <article> <h2>{{ $post->title }}</h2> {{ $post->summary }} </article> -
Toby Steward revised this gist
Aug 6, 2013 . 4 changed files with 5 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -17,4 +17,4 @@ public function showPosts() return View::make('blog', array('posts' => $posts)); } } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -7,7 +7,7 @@ class Post extends Eloquent * * @var string */ protected $table = 'posts'; /** * Define guarded columns This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -12,7 +12,7 @@ <h1>Posts</h1> <div class="posts"> @include('posts') </div> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script> @@ -51,4 +51,4 @@ function getPosts(page) { </script> </body> </html> This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -7,4 +7,4 @@ @endforeach {{ $posts->links() }} -
Toby Steward revised this gist
Aug 6, 2013 . 1 changed file with 10 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,10 @@ @foreach ($posts as $post) <article> <h2>{{ $post->title }} <a href="#{{ $post->id }}">#{{ $post->id }}</a></h2> {{ $post->summary }} </article> @endforeach {{ $posts->links() }} -
Toby Steward revised this gist
Aug 6, 2013 . 1 changed file with 15 additions and 23 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -19,43 +19,35 @@ <script> $(window).on('hashchange', function() { if (window.location.hash) { var page = window.location.hash.replace('#', ''); if (page == Number.NaN || page <= 0) { return false; } else { getPosts(page); } } }); $(document).ready(function() { $(document).on('click', '.pagination a', function (e) { getPosts($(this).attr('href').split('page=')[1]); e.preventDefault(); }); }); function getPosts(page) { $.ajax({ url : '?page=' + page, dataType: 'json', }).done(function (data) { $('.posts').html(data); location.hash = page; }).fail(function () { alert('Posts could not be loaded.'); }); } </script> </body> -
Toby Steward renamed this gist
Aug 6, 2013 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
Toby Steward revised this gist
Aug 6, 2013 . 3 changed files with 81 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -15,6 +15,6 @@ class BlogController extends Controller return Response::json(View::make('posts', array('posts' => $posts))->render()); } return View::make('blog', array('posts' => $posts)); } } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ <?php class Post extends Eloquent { /** * The database table used by the model. * * @var string */ protected $table = 'blog_posts'; /** * Define guarded columns * * @var array */ protected $guarded = array('id'); } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,62 @@ <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>Laravel AJAX Pagination with JQuery</title> </head> <body> <h1>Posts</h1> <div class="posts"> @include('posts'); </div> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script> <script> $(window).on('hashchange', function() { if (window.location.hash) { var page = window.location.hash.replace('#', ''); if (page == Number.NaN || page <= 0) { return false; } $.ajax({ url : '?page=' + page, dataType: 'json', }).done(function (data) { $('.posts').html(data); location.hash = page; }).fail(function () { alert('Posts could not be loaded.'); }); } }); $(document).ready(function() { $(document).on('click', '.pagination a', function (e) { var page = $(this).attr('href').split('page=')[1]; $.ajax({ url : '?page=' + page, dataType: 'json', }).done(function (data) { $('.posts').html(data); location.hash = page; }).fail(function () { alert('Posts could not be loaded.'); }); e.preventDefault(); }); }); </script> </body> </html> -
Toby Steward created this gist
Aug 6, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,20 @@ <?php class BlogController extends Controller { /** * Posts * * @return void */ public function showPosts() { $posts = Post::paginate(5); if (Request::ajax()) { return Response::json(View::make('posts', array('posts' => $posts))->render()); } return View::make('test', array('posts' => $posts)); } }