title: Yii2 calling javascript function at another file
body: <p>I have a js file and a index file which are located in the same folder. This is my form. I have already register the script already too.</p>
  
  <pre><code>$this-&gt;registerJs($this-&gt;render('script.js'), \yii\web\VIEW::POS_READY);
  
  &lt;?php $form = ActiveForm::begin(); ?&gt;
  &lt;div class="booth"&gt;
      &lt;video id="video" width="400" height="300"&gt;&lt;/video&gt;
      &lt;a href="#" id="capture" class="button"&gt;Take Photo&lt;/a&gt;
      &lt;canvas id="canvas" width="400" height="300"&gt;&lt;/canvas&gt;
  &lt;/div&gt;
  
  &lt;div class="form-group"&gt;
         &lt;?= Html::button('Save',['class'=&gt;'btn btn-primary','onclick'=&gt;'saveimage();']) ?&gt;
  &lt;/div&gt;
  
   &lt;?php ActiveForm::end(); ?&gt;
  </code></pre>
  
  <p>This is the function inside the js file.</p>
  
  <pre><code>function saveimage()
  {
      var csrfToken = $('meta[name="csrf-token"]').attr("content");
  
      console.log(123);
  
      })*/
  }
  </code></pre>
  
  <p>When I clicked my button is show error <code>Uncaught Reference Error: saveimage is not defined</code>? Its there anyway to call the function?</p>
  
  <p>I tried <code>'onclick'=&gt; 'js:saveimage()'</code> too, but still not working.</p>