2

I'am making use of laravel pagination($data->links()) for ajax pagination using below code.

$(document).on("click", '.pagination a', function(e) {
    e.preventDefault();
    var url = $(this).attr('href');
    loadArts(url);
});

function loadArts(url) {
    $.ajax({
        url : url
    }).done(function (data) {
        $(".image-masonry").html(data);

        jsIntializations()
    }).fail(function () {
        alert('Articles could not be loaded.');
    });
}

it's working fine, but upon clicking back button from an inner page, browser returning back to page1. Here is the controller function

public function index(Request $request)
{
    $arts = Art::with('artist')->orderBy('id','ASC')->paginate(10);
    if($request->ajax()){            
        return view('art::art.list', compact('arts');
    }
    return view('art::art.index', compact('arts');
}

.image-masonary is the class in index.blade.php to which contents of list.blade.php is being loaded upon pagination.

This is the url : http://localhost:8000/admin/arts

I tried this method , history.pushState({ path: url }, '', url);

then back button is taking ajax route, but getting only broken view.

Geethu
  • 348
  • 6
  • 24
  • Hi @Shalom, do you mange to solve this? Im having same issue with yours on history.pushState issue... looking forward to hear from you. – Wai Mun Oct 05 '17 at 05:03
  • @Wai Mun, not yet my friend. I'm now busy with other works, so not able to work on it. Please let me know once you find it.Thank you. – Geethu Oct 05 '17 at 05:32
  • feel free to check my answer below. I tried it and it worked superb-ly... – Wai Mun Oct 05 '17 at 07:30

1 Answers1

0

You may refer to the answer below

https://blog.pisyek.com/browsers-back-button-issue-after-logout-laravel-5 https://laracasts.com/discuss/channels/requests/back-button-browser?page=1

Wai Mun
  • 194
  • 10