• Empleos
  • Sobre nosotros
  • profesionales
    • Inicio
    • Empleos
    • Cursos y retos
  • empresas
    • Inicio
    • Publicar vacante
    • Nuestro proceso
    • Precios
    • Evaluaciones
    • Nómina
    • Blog
    • Comercial
    • Calculadora de salario

0

488
Vistas
How to calling javascriprt function in laravel blade after mix

in here i have stuck mind and cannot found how to solve this

i have a file app.js & form.js

in app.js i have some code like:

require('bootsrap');
require('./form.js');

in form.js i have function code like:

function saveform(somevariable) {
 // some code
}

then mix that app.js file

after that i'm call saveform(somevariable) function into laravel blade file lets we call as form.blade.php

<html>
 <head></head>
 <body>

  <script>
   var somvariable = 'some attribute';
   
   saveform(somevariable);
  </script>

  <script src="{{ mix('js/app.js') }}"></script>
 </body>
</html>

and i have and error like this in browser

ReferenceError: tinymceInit is not defined
about 3 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Use window

in app.js

require('bootsrap');
window.form = require('./form.js');

in form.js

export function saveform(somevariable) {
 // some code
}

in form.blade.php

<html>
 <head></head>
 <body>
  <script src="{{ mix('js/app.js') }}"></script>
  <script>
   var somvariable = 'some attribute';
   
   window.form.saveform(somevariable);
  </script>
 </body>
</html>
about 3 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recomiéndame algunas ofertas
Necesito ayuda