• Jobs
  • About Us
  • Jobs
    • Home
    • Jobs
    • Courses and challenges
  • Businesses
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

526
Views
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
over 3 years ago · Juan Pablo Isaza
1 answers
Answer question

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>
over 3 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Show me some job opportunities
There's an error!