A
A
axblue2017-02-03 14:23:01
Laravel
axblue, 2017-02-03 14:23:01

How to load layout when navigating back through the page using ajax?

Hello. The essence is this:
I load elements into the block with Ajax. I send an ajax request to the controller, in the controller I look at the ajax request or not, if ajax then

if ($request->ajax()) {
            return view('includes.recipe-card-col-3', ['posts' => $posts])->render();
        }

Everything is fine here, everything works, the elements come. The problem is that when I navigate through an element, and then with the back button in the browser, the elements are naturally loaded again, but without the layout ... How can I solve this? Naturally, I do not want to load the entire page with Ajax, but only the content.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
anton_lazarev, 2017-02-03
@anton_lazarev

There is an HTML5 History/State API for the "Forward" and "Back" buttons and, in particular, for working with it History.js https://github.com/browserstate/history.js/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question