title: How can I use registerJS() to produce the following script tag?
body: <p>I have the following JS code that I am placing on the top of my view file. I need to use <code>registerJS()</code> because right now Yii2 loads jQuery after my script. Note that all questions on <code>registerJS()</code> load an external file.</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  $(document).ready(function() {
      $('#filter').hide();
      $('a.view_more1').live("click", function(e) {
          var views = "";
          $(".views input:checked").each(function() {
              views += this.value+',';
          });
          offset = document.getElementById('offset').value;
          var record = document.getElementById('record').value;
          var record1 = document.getElementById('record1').value;
          var url = '&lt;?php //echo URL; ?&gt;' + 'products/all_products_1?offset=' + offset + '&amp;record=' + record+'&amp;views='+views+'&amp;main='+'&lt;?php echo $cat; ?&gt;'+'&amp;sub='+'&lt;?php echo $sub_cat; ?&gt;'+'&amp;sec='+'&lt;?php echo $sec_cat; ?&gt;'+'&amp;third='+'&lt;?php echo $third_cat; ?&gt;'+'&amp;price1='+price_text;
          $.post(url, function(check) {
              if (check) {
                  $('#product').append(check);
                  $('#loading').show();
                  $('.wloader_img').hide();
                  offset = parseInt(offset) + 12;
                  $("#offset").val(offset);
                  if (offset &gt;= record1) {
                      $('#loading').hide();
                  }} });  }); });
  &lt;/script&gt;
  </code></pre>