Rails version 6.0.2.1, Ruby version 2.6.3
I am trying to jquery to render a partial inside a view after the page has been loaded.
This is my javascript file (app/packs/organisation/show/organisation_insights.js.erb):
$(document).ready(function() {
$('#insights-statistics').html('<%= render "organisations/partials/ajax/test" %>');
});
This is my view:
<div class="card organisation-insights" id="organisation-insights">
<div class="card-header">Insights</div>
<div class="card-body" id="insights-statistics">
Loading...
</div>
</div>
<%= javascript_pack_tag "organisations/show/organisation_insights" %>
and this is the partial I am trying to render
<p>Test To Render</p>
However, when I run this in a browser, I get the following error:
Uncaught Error: Module build failed (from ./node_modules/rails-erb-loader/index.js):
Error: rails-erb-loader failed with code: 1
at ChildProcess.<anonymous> (:3000/home/vineet/workspace/conneqt/node_modules/rails-erb-loader/index.js:128)
at ChildProcess.emit (events.js:311)
at maybeClose (internal/child_process.js:1021)
at Socket.<anonymous> (internal/child_process.js:443)
at Socket.emit (events.js:311)
at Pipe.<anonymous> (net.js:668)
at Object../app/javascript/packs/organisations/show/organisation_insights.js.erb (bootstrap:83)
at __webpack_require__ (bootstrap:19)
at bootstrap:83
at bootstrap:83
./app/javascript/packs/organisations/show/organisation_insights.js.erb @ bootstrap:83
__webpack_require__ @ bootstrap:19
(anonymous) @ bootstrap:83
(anonymous) @ bootstrap:83
After googling, I tried following the recommendation posted here (https://github.com/usabilityhub/rails-erb-loader/issues/63#issuecomment-374791504) but it did not help resolve the issue.
How can I get this to work?