0

I am working on an application that has a custom model that works like this:

openFastModal(content);

I tried to use a blade to get the content:

var content =  '{!! view('forms.help') !!}'

This does not work, The content variable get rendered wrong

enter image description here

How can I add the content of a blade into a javascript variable as a string?

Amit Bisht
  • 329
  • 3
  • 15
Mister Verleg
  • 4,053
  • 5
  • 43
  • 68
  • please do not do this: https://stackoverflow.com/questions/23740548/how-to-pass-variables-and-data-from-php-to-javascript – online Thomas Jun 29 '18 at 08:07

1 Answers1

1

You should include your file using backtick

`{!! view('forms.help') !!}`

Or replace newline characters with space in forms.help

the backtick version will work on newer browser that support es6 syntax although right now all major browser support it check brower support

but if you want to support old browser you should replace newline characters with space in your forms.help

Amit Bisht
  • 329
  • 3
  • 15