Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

231
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda