0

I have 2 parts in my main layout: @yield('styles') @yield('scripts')

In the other template files which extended the main layout, I use @section('styles') and @section('scripts')

When I am loading partial views, all the styles in the 'styles' sections are loading well. But, about the scripts, only the first partial view's scripts are loading and for the others, it ignores them.

Any Idea or experience before?

2
  • Let's see your code. Commented Feb 15, 2016 at 7:20
  • Have you remembered to add the @stop for the end of each @section? If so, let's see the code as Muhammet said and we can figure it out! Commented Feb 15, 2016 at 10:46

1 Answer 1

6

have you looked at @stack?

@stack('css') and @stack('scripts') instead of @yeild

you can then do

@push('scripts')
<script> /js/jquery.js</script>
@endpush

That way you can push different scripts or css to the header or footer depending on your template page

https://laravel.com/docs/5.2/blade#stacks

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.