How does blade handle script calls?

2019-05-24 07:47发布

Hi once again everyone.

I'm having a problem with script calls. I'm using blade in laravel.

Everything is working the right way except the scripts calling, which support search and order functions.

Here is my hierarchy and respective relevant code:

main.blade.php

...

    <div class="page-container">

      @include('layouts.sidebar')

      <!-- BEGIN CONTENT -->

      <div class="page-content-wrapper">

        <div class="page-content">

         @yield('body')

       </div>

     </div>

   </div>

 . . .

        <script src="{{ URL::asset('/assets/global/scripts/datatable.js') }}" type="text/javascript"></script>
        <script src="{{ URL::asset('/assets/global/plugins/datatables/datatables.min.js') }}" type="text/javascript"></script>
        <script src="{{ URL::asset('/assets/global/plugins/datatables/plugins/bootstrap/datatables.bootstrap.js') }}" type="text/javascript"></script>
        <script src="{{ URL::asset('/assets/pages/scripts/table-datatables-managed.min.js') }}" type="text/javascript"></script>

      </body>

      </html>

permissions.blade.php

@extends('mainPage.main')

@section('body')

. . .

@yield('userListBody')

. . .

userList.blade.php

@extends('administration.permissions')

@section('userListBody')

. . .

And this produces the following User List View

while when I use the following structure for a different view:

main.blade.php

listagem.blade.php

@extends('administration.permissions')

@section('userListBody')

. . .

File List View

as you can see it doesn't apply pagination, search or order function even though it's loaded.

Script Load

The script that is handling this is called here

<script src="{{ URL::asset('/assets/pages/scripts/table-datatables-managed.min.js') }}" type="text/javascript"></script>

I've been trying to get this to work but unsuccessfully. What am I missing?

Also if I move the script call to the userList it doesn't work either.

Thanks in advance and if anything else needed ask so I can provide the necessary information.

Edit 1: After finishing some other stuff I was doin in this project decided to get back at this...

I think it may be important to add this information script.js

var TableDatatablesManaged = function() {
    var e = function() {
            var e = $("#sample_1");
            e.dataTable({ . . . });

And I've tried to remove the script call from the main.blade.php and add to end of listagem.blade.php and permissions.blade.php and it doesn't work on both views.

I have this same line in both views

<table class="table table-striped table-bordered table-hover order-column" id="sample_1">

I've also made another function with another name and tried to call it on listagem.blade.php changing the id but without success again.

0条回答
登录 后发表回答