A
A
Anton Natarov2016-04-20 13:05:54
Yii
Anton Natarov, 2016-04-20 13:05:54

Yii2 jQuery not executing, how to fix?

In Layout I connect my script

$this->registerJsFile('@web/js/file.js', ['depends' => [\yii\web\JqueryAsset::className()]]);

In the source code, I see that the script is connected below all the others, i.e. after loading jquery.
At the same time, I can get into my script from the source file and read it.
But the script itself does not work. As a test, I made a function on click on the Div Block.
$('#header-holder').click(function(){
   alert("Okay");
});

No matter how many clicks, it doesn't work. What could be the problem ? Css TO normally connected through assets ..

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Bay, 2016-04-20
@HanDroid

see js errors. If not, check for duplicate IDs.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question