0

I am loading just one section from a Laravel Blade view using jQuery AJAX, following this approach. This is working fine.

The Blade view I'm loading a section from also has a couple of Blade stacks. How can I include those stacks in the AJAX response?

I've tried nesting the stacks inside the view section I'm calling, but the stacks still were not included in the response (though the stacks still work on the original complete view just fine).

FYI, the stacks are 'modals' (containing some Bootstrap modals) and 'scripts' (containing some JavaScripts).

Thanks!

EDIT

I used the wrong terms earlier. I said my view had stacks, when I should have said my view pushed to stacks:

@section('content')
<div>Hello, world.</div>
@endsection

@push('modals')
@include('modals.foo')
@include('modals.bar')
@endpush

@push('scripts')
<script src="example.js"></script>
<script src="another.js"></script>
@endpush

I want these 3 parts to be added to my page via AJAX ('content' section; which is working, and 'modals' push and 'scripts' push; which I need help with).

  • Once the base page is loaded, whatever stacks it came with it can't be affected anymore. Surely you can `render()` a AJAX reply and send it as html to a modal. Simply include them before rendering. As long as there is no `document.ready(){...}`, your jQuery code will be triggered. If I'm not mistaken, stacks are added after the page has been rendered. If that's the case, it explains why your stacks aren't included in the AJAX response. – Dimitri Mostrey May 08 '19 at 15:56
  • @DimitriMostrey I realized I wasn't clear in my question on the structure of my blade, so I added an edit. Could you let me know if that impacts your comment? And clarify "Simply include them before rendering"? Thanks so much – stackingjasoncooper May 08 '19 at 17:38

0 Answers0