Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

229
Views
Getting a value on a different .js file on a blade.php

My issue is const SELECTED_CATEGORY_ID

I have these sets of scripts in my index.blade.php in my laravel:

@section('scripts')
    <script type="text/javascript">
        const PROFILE_NON_BBR_EXTERNAL_ROUTE = "{{ route('non-bbr-external') }}";
        const BBR_GROUP_NAME = "{{ route('bbr-group-configuration-all') }}";
        const DATATABLE = "{{ route('bbr-category-configuration-datatable') }}";
        const SELECTED_CATEGORY_ID = data.category_id;
    </script>
    <script type="text/javascript" src="{{asset('js/sweetalert.min.js')}}"></script>
    <script src="{{asset('/modules/bbr-category-configuration/js/app.js')}}"></script>
@endsection

in the last script: app.js, there is a value inside a button that I need to retrieve which is:

 value="${row.category_id}"

below is the full output for a bit of context.

let TABLE = $('#categoryList').DataTable({
  columns: [
                { data: 'id', name: 'id', width: '10%', orderable: false, searchable: false,
                render: (data, type, row) =>{
                    let html = "";
                    if(row.category_name && row.category_name.toUpperCase() !== "GENERAL"){

                        html += `<ul class="list-inline no-margin">`;
                            html += `<li class="list-inline-item">
                                        <button type="button" value="${row.category_id}" id="edit_category" class="edit_category btn btn-outline-secondary"><i class="fas fa-edit" aria-hidden="true"></i> Edit</button>
                                     </li>`;
    
                        html += `</ul>`;
                    }

                    return html;
                }
            }
});

What do I need to use in order to retrieve that data from app.js? Using this one will just get me DATATABLE is not defined error:

const SELECTED_CATEGORY_ID = data.category_id;

1

UPDATE:

  • question, what will I need to do to get the variable from app.js and onto my const?
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!