Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

74
Views
How to setup jQuery properly for rails v5.2

My views/comments/create.js.erb JS is not working and my erb does give some output, I setup my jQuery by adding

gem 'jquery-rails', '~> 4.4'

I bundles my rails app and made changes in the app/asset/javascript/application.js with the requires as follows

//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require_tree .
//= require activestorage

So when i write my js for create action of comment in app/views/comments/create.js.erb

$('#comment_content').val('')
$('#comment_div').prepend(<%= j render @comment %>)

And i have a partial with _comment.html.erb

<%= comment.created_at.strftime("%l:%M:%p")%>
<b><%= comment.user.username %></b>
<%= comment.content %>
<br>

Now i dont know where i have made mistake in setting up my jquery

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The answer to this is to use "" in the prepend function just like

$('#comment_content').val('')
$('#comment_div').prepend("<%= j render @comment %>")
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!