Note that there are some explanatory texts on larger screens.

plurals
  1. PORender template having Jquery datatables in .js.erb file
    text
    copied!<p>I am currently working on a project where I am implementing several reports. The report filters are remotely submitted to my action and the return results are displayed in Datatable with searching,sorting and pagination. </p> <p>I have a drg.js.erb file which is having code like this :</p> <pre><code>var html = "&lt;%= escape_javascript(render(partial: 'drg_datatable',formats: [:html],locals: {result: @result})) %&gt;"; $("#datatable-result").append(html); </code></pre> <p>The partial _drg_datatable.html.erb is having datatable implemented like this. Below is my _drg_datatable.html.erb file :</p> <pre><code>&lt;% if result %&gt; &lt;table id="results" class="table table-striped table-bordered display"&gt; &lt;% case params[:view] %&gt; &lt;% when "ahfs" %&gt; &lt;%= datatable_ahfs_result(result) %&gt; &lt;% when "drg_code" %&gt; &lt;%= datatable_drg_result(result) %&gt; &lt;% when "inpharmics_id" %&gt; &lt;%= datatable_inpharmics_id_result(result) %&gt; &lt;% when "provider" %&gt; &lt;%= datatable_provider_result(result) %&gt; &lt;% else %&gt; &lt;% end %&gt; &lt;/table&gt; &lt;% end %&gt; </code></pre> <p>The problem I am facing is that when I render the partial _drg_datatable.html.erb using .js.erb file it creates the table but escapes the javascript to add sorting,pagination and other cool features we get in Jquery Datatables. Can someone point me how should I go about doing this ? I have tried to render the partial is .js.erb without writing escape_javascript but then the partial does not get rendered at all.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload