mardi 27 octobre 2015

Laravel 5.1 - Refresh page on Ajax Navigation

In my app i have configured my navigation with ajax, so i can get my view's content (so only pure HTML) very quickly. I've also implemented javascript's history, so i can modify url on navigation.

But when i refresh the page on a url like my-app-/news, of course i get the same content asked by ajax: the view with only html, but in this case i need a complete view, not only the content.

route.php

Route::get('/', 'PagesController@index');
Route::get('/{page}', 'PagesController@ajaxCall');

PagesController.php

class PagesController extends Controller {

    public function index(){
        return view('pages.index');
    }

    public function ajaxCall($page){
        return view('content.'.$page)->render();
    }

}

How to create another route and method like my index where i can call the full view on page refresh?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire