0

in my research I found that one can use this method:

$this->registerJsFile()

However, when I use it I get this error:

Calling unknown method: frontend\controllers\AvailableController::registerJs()

1
  • 1
    You should follow MVC design pattern, js is related to views Commented Jun 13, 2016 at 19:06

1 Answer 1

1

The method:

registerJs($url, $options = [], $key = null)

is defined in the yii2/web/View class. The $this object in your example is an instance of your AvailableController class, that presumably extends the Controller class. That's why you get the error.
You should use the $this object of one of your views.
Try to go to to your views/available folder, open a view there (for example, view.php), identify your $this object, and call registerJs() from there.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.