mercredi 28 octobre 2015

Laravel 5.1 - Javascript not loaded

My app gets the views from an ajax request by navigation. So when i click a link in my menu i retrieve all the Html that my view contains.

My javascript is included inside the main template and of course all my calls works. But once i need for example to create an animated filter gallery inside a specific view, the javascript for that view doesn't work.

This is how i've organized my app:

My template

<!-- !Doctype -->
@include('partials.doctype')

<!-- Menu -->
@include('partials.menu')

<!-- Cont -->
<section id="content-wrapper">
    @include('ajax.index')
</section>

<!-- Footer -->
@include('partials.footer')

<!-- Javascript -->
@include('partials.javascript')

</body>
</html>

My Controller (if there's an ajax call i retrieve the view without @extends() and @section(), otherwise i retrieve my full view):

// load page
public function loadPage($page){
    return (\Request::ajax()) ? view('ajax.'.$page)->render() : view('pages.'.$page);
}

My views:

For my purpose i've created 2 type of views, one extended and one with only the html i need from my ajax calls.

a) extended, it's inside "pages" folder:

@extends('main')
@section('cont')

@include('ajax.shop')

@stop

b) only html, for ajax calls, inside "ajax" folder:

<div class="content">
    <div class="container-fluid">
        <div class="row page-title-box">
            <h3 class="page-number">N. 67</h3>
            <h1 class="page-title">Shop</h1>
        </div>
    </div>
</div>

I don't understand where to put my javascript for this view if i need to implement an animated filter gallery. I've tried to put javascript inside the view but my app crashed.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire