Following @AliMasudianPour on this topic instructions I was able to get Jquery working on my dev/prod environment on my remote server without problem. However, on my local server running on a Mamp. Jquery insistis on not work. I keep getting the errors:
$ is not defined
jQuery is not defined
yii is not defined
Cannot read property ‘fn’ of undefined
I've compared all AppAssets and Conf lines on the Common and Frontend directories between local and remote installation.
Probably I'm skipping some important step. Could someone give me some hint on what could be?
Some snippets from my code:
frontend/assets/AppAsset.php
<php
namespace frontend\assets;
use yii\web\AssetBundle;
class AppAsset extends AssetBundle
{
public $basePath = '@webroot';
public $baseUrl = '@web';
public $css = [
'css/main.css',
];
public $js = [
'js/jquery-1.11.3.min.js',
];
public $jsOptions = [
'position' => \yii\web\View::POS_HEAD
];
public $depends = [
];
}
on frontend/config/main.php
inside components:
'assetManager' => [
'bundles' => [
'yii\bootstrap\BootstrapPluginAsset' => [
'js'=>[]
],
'yii\bootstrap\BootstrapAsset' => [
'css' => []
],
'yii\web\JqueryAsset' => [
'sourcePath' => null,
'js'=>[]
],
],
],
on the layout in view:
use frontend\assets\AppAsset;
AppAsset::register($this);
by the way, it works for other js scripts, only not to jquery!