Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9046341
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T11:38:48+00:00 2026-06-16T11:38:48+00:00

I’m having a problem where I try to render a partial through a js.erb

  • 0

I’m having a problem where I try to render a partial through a js.erb after I obtain some data from my controller. I’ve tried a number of different things, I just can’t get the partial to render. The log file shows the partial rendering with a 200 OK message, but nothing happens on the page. This post is similar to the problem I am having:

Rails 3 – render partial js.erb

I have tried to follow the guidance this post, but I’m still having trouble.

Here is my partial with the form __left_date_filter.html.erb =>

    <%= form_tag({:controller => 'events', :action => 'dateFilter'}, :class => 'date_form', :remote => true) do %>
    <%= datepicker_input "event", :start_date, :class => 'dateFilter', :dateFormat => 'mm/dd/y' %>
    <%= datepicker_input "event", :end_date, :class => 'dateFilter', :dateFormat => 'mm/dd/y' %>
    <%= submit_tag "Submit" %>
    <% end %> 

Here is the generated HTML =>

    <form accept-charset="UTF-8" action="/events/dateFilter" class="date_form" data-remote="true" method="post">
    <div style="margin:0;padding:0;display:inline">
    <input name="utf8" type="hidden" value="&#x2713;" />
    <input name="authenticity_token" type="hidden" value="x4cbSoYnUu2+W6qvtPnKXvXR8Tp3Yh7BP9W0RMyR02g=" /></div>
    <input class="dateFilter" id="event_start_date" name="event[start_date]" size="30" type="text" /><script type="text/javascript">

    //<![CDATA[
    jQuery(document).ready(function(){jQuery('#event_start_date').datepicker({"dateFormat":"mm/dd/y"})});
    //]]>
    </script>
   <input class="dateFilter" id="event_end_date" name="event[end_date]" size="30" type="text" /><script type="text/javascript">
   //<![CDATA[
   jQuery(document).ready(function(){jQuery('#event_end_date').datepicker({"dateFormat":"mm/dd/y"})});
   //]]>
</script>
    <input name="commit" type="submit" value="Submit" />

Here is the dateFilter.js.erb =>

$('#content').html("<%= escape_javascript(render(:partial => 'dateFilter')) %>");

Here is the events_controller =>

 def dateFilter

   eventIn = params[:event]
   start_date = Date.parse(eventIn[:start_date])
   end_date = Date.parse(eventIn[:end_date])
   sql = *redacted*

   @events = Event.find_by_sql(sql)

   respond_to do |format|
      format.html
      format.json
      format.js
  end
end

Here is the application.js =>

$(document).ready(function() {

  $('#date_form').submit(function (){  

    $.ajax({
     type: 'POST',
     url: "/events/dateFilter", 
     beforeSend: function (xhr) {xhr.setRequestHeader("Accept", "text/javascript");},
     data: { 'start_date' : $("input[name='event[start_date]']").datepicker(), 'end_date' : $("input[name='event[end_date]']").datepicker()}
     success: function(data) { $('#content').html(response); }
    });

 });

This is log data from the server =>

    Started POST "/events/dateFilter" for 127.0.0.1 at 2012-12-20 12:18:57 -0500
    Processing by EventsController#dateFilter as JS
    Parameters: {"utf8"=>"✓", "authenticity_token"=>"x4cbSoYnUu2+W6qvtPnKXvXR8Tp3Yh7BP9W0RMyR02g=", "event"=>{"start_date"=>"07/01/12", "end_date"=>"07/02/12"}, "commit"=>"Submit"}

     **shows SQL Statement getting all records**

    Rendered events/_dateFilter.html.erb (89.1ms)
    Rendered events/dateFilter.js.erb (90.7ms)
    Completed 200 OK in 212ms (Views: 80.5ms | ActiveRecord: 128.2ms)

Then finally, the page I wish to render _dateFilter.html.erb =>

<div class="content">
<table class="table table-striped table-hover">
  <thead>
    <tr>
      <th><%= sortable  "event_id" %></th>
      <th><%= link_to "Time Created", :sort => "event_date_time_local" %></th>
      <th><%= link_to model_class.human_attribute_name(:event_type_id), :sort => "event_type" %></th>
      <th><%= link_to model_class.human_attribute_name(:severity_id), :sort => "severity_name" %></th>
      <th><%= link_to "Examined", :sort => "event_examined" %></th>
      <th><%= link_to model_class.human_attribute_name(:action_required), :sort => "action_required" %></th>
      <%#<th><%= model_class.human_attribute_name(:comments) </th>%>
      <th><%= link_to model_class.human_attribute_name(:initials), :sort => "initials" %></th>
      <th><%= link_to "Ticket ID", :sort => "taskid" %></th>
    </tr>
  </thead>
</div>

I’m just not sure why it is telling me that it rendered the partial properly, but then nothing happens on my page. I’m not very familiar with JQuery, so there is probably something wrong in my application.js or my datefilter.js.erb files.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T11:38:49+00:00Added an answer on June 16, 2026 at 11:38 am

    A few things:

    • The ajax call is not necessary if you are using :remote => true in your form_tag. JQuery will handle the call to Rails automatically. You should be able to comment out the code in application.js.
    • Make sure you have a div that has id="content" in your HTML already.
    • It’s not clear where you are getting a lot of the ruby variables in your _dateFilter.html.erb. Could you start with a simple partial to see if it works, and then you can start adding in details from the @events variable passed from the controller:

    .

    <div class="content">
     <table>
        <thead>
           <tr>
              <th>Test</th>
           </tr>
        </thead>
     </table>
    </div>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I am currently running into a problem where an element is coming back from
I am using jsonparser to parse data and images obtained from json response. When
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I've tracked down a weird MySQL problem to the two different ways I was
I have a text area in my form which accepts all possible characters from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.