laracasts / PHP-Vars-To-Js-Transformer

Transform PHP data to JavaScript.
https://packagist.org/packages/laracasts/utilities
MIT License
2.21k stars 219 forks source link

Uncaught ReferenceError: path is not defined #74

Closed giwrgos88 closed 7 years ago

giwrgos88 commented 8 years ago

I have did exactly what the README says to install the library on my laravel project.
So my composer has

"laravel/framework": "~5.1",
"pingpong/modules": "dev-feature/5.1",
"cartalyst/sentinel": "~2.0",
"laracasts/utilities": "~2.0"

Then on my app.php i have the following

'providers' => [Laracasts\Utilities\JavaScript\JavaScriptServiceProvider::class] 'aliases' => ['JavaScript'=> Laracasts\Utilities\JavaScript\JavaScriptFacade::class]

So in my class i added the javascript like this use JavaScript; and then I initialized it as follows \JavaScript::put([ 'path' => 'gi', ]);

but it keeps shown me "Uncaught ReferenceError: path is not defined"

Here is the way how i including the .js file from my blade template @section('scripts') < script src="{!! Module::asset('portfolio/portfolio.js') !!}"></ script> @stop

What I'm doing wrong?

willvincent commented 8 years ago

Did you change the namespace to something other than the default window ? If that value is anything other than window, for example if you changed it to foobar, you have to prefix any values you pass with what you changed it to. That doesn't need to be specified if the value is window as that is the global namespace in a browser.

but if you changed it to foobar, then you'd have to get to your path value as foobar.path