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 869409
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T10:18:04+00:00 2026-05-15T10:18:04+00:00

I’m trying to insert a partial into a jquery dialog box. The dialog box

  • 0

I’m trying to insert a partial into a jquery dialog box. The dialog box is working but no partial..

Here is my code :

application.js

$(document).ready(function(){
    $("#add_note").click(function(){
        $("#notes").html("<%= escape_javascript(render(:partial => @note)) %>").dialog({title: 'Basic Dialog'})
    })
})

my view

<div class="title">
        <span>Historique :</span>
        <span id="add_note">Ajouter une note</span>
      </div>

      <div id="notes">
      </div>

my partial
in myview/_note.html.erb

<div class="note">
    <%= form_for(@add_note) do |f| %>
        <dl>
          <dt>Type de note</dt>
          <dd><%= f.collection_select :note_type_id, NoteType.find(:all), :id, :label, :allow_blank => "Type" %></dd>
        </dl>
         <dl>
          <dt>Titre :</dt>
          <dd><%= f.text_field :title %></dd>
        </dl>
        <dl>
          <dt>Description :</dt>
          <dd><%= f.text_field :description %></dd>
        </dl>
        <%= f.hidden_field :project_id, :value => @project_id %>
        <%= f.hidden_field :organization_id, :value => @project.organization_id %>
        <%= f.hidden_field :user_create_id, :value => current_user.id %>
        <%= f.hidden_field :domain_id, :value => current_user.domain_id %>
        <%= f.hidden_field :created_at %>

        <div class="actions">
          <%= f.submit %>
        </div>
      <% end %>

If you have a clue, it would be very helpful!
Thanks

Fabien

  • 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-05-15T10:18:05+00:00Added an answer on May 15, 2026 at 10:18 am

    The application.js file is a place for static JavaScript. It is not passed to ERB for processing on each request, so your <%= code %> is never run. If you point your browser to /javascripts/application.js you’ll see what I’m talking about.

    Make sure you have a good handle on how requests are processed in Rails. You may be missing some details here. application.js is a static file that exists in the /public/javascripts directory, so it is served up directly by your web server; Rails doesn’t even get touched when the browser fetches it. It is just like when you create a new rails app and you have to erase the /public/index.html file before Rails can process your map.root in the routes.rb file.

    You have a few different options:

    Here is an older Railscast episode, but it’s seems close to what you are looking for. It uses a controller named javascripts_controller for generating dynamic javascripts. This is not a very fine grained approach.

    In this episode, the method Ryan uses for adding fields for a nested model can be adapted to fit your needs. I have used this method a few times and it works very well.

    Recommended Method

    You can also call an action that returns the html of the partial via ajax and use the result to $(#notes).html(result). A quick search on rails jquery ajax offers a few guides on how to implement this (Here is one that seems reasonable). Here is another Railscast episode that deals with jQuery and Rails 2. I wouldn’t recommend using jRails at this point because it’s fairly outdated, and as the episode mentions, it kind of defeats the purpose of switching to jQuery as the Rails 2 helpers generate obtrusive JavaScript.

    This is a flexible way of doing things. You have a generic set of static JavaScript used to call remote methods. In individual controller methods, you can respond_to these ajax calls and return JavaScript with dynamic data, html, or JSON.

    The methods in jQuery to look at for ajax are listed in this section of the jQuery api. $.ajax $.post and $.get are the main ones.

    For your example, the $.get would be a good place to start. Here is an example right from the api docs:

    $.get('ajax/test.html', function(data) {
      $('.result').html(data);
      alert('Load was performed.');
    });
    

    Here is a Railscast on how Rails 3 handles unobtrusive JavaScript along with HTML5 custom attributes. You can mimic this approach in Rails 2, but the standard helper methods wont generate the data-remote, data-method, data-disable-with, or other data-* attributes for you. You can see in the jQuery version of the Rails 3 ujs, that it is most like the previous method I mentioned where controller methods are called with $.ajax and handle the response differently depending on the dataType (which is ‘script’ by default.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 435k
  • Answers 435k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I have read an article which can help you in… May 15, 2026 at 3:44 pm
  • Editorial Team
    Editorial Team added an answer I believe I came across one by Paul Johnston at… May 15, 2026 at 3:44 pm
  • Editorial Team
    Editorial Team added an answer There is no simple/automatic way. You have to parse the… May 15, 2026 at 3:44 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.