Topic: Error using JqueryUI in Rails

I use ckeditor to render WYSIWYG text editor fields. I am implementing a "canned reply" feature to allow users to save frequently used email replied, then re-use them.

Here is a snipped of the code on my "new email" page in my recently upgraded rails3 application:

<div id="popup-form" title="popup" style="display:none">

<%= link_to  "Insert Canned Reply", popup_canned_responses_activities_url(:ta =>"task"), :remote => true %>

Then I have popup_canned_responses.js.erb which renders my 'canned_responses' partial in a JqueryUI modal box:

  autoOpen: true,
  height: 100,
  width: 300,
  modal: true,
  title: 'Insert Canned Response',
  open: function() {
    $("#popup-form").html("<%= escape_javascript(render(:partial => 'canned_responses', :locals => {:ta => params[:ta]})) %>")

here is the canned_responses partial:

<%= form_tag('/activities/load_canned_response', :remote => true) do %>
  <%= select_tag "canned_id", options_from_collection_for_select(CannedResponse.all, :id, :name) %>
  <%= hidden_field_tag "ta", params[:ta] %>
  <%= submit_tag "Select" %>
<% end %>

So far so good, the JqueryUI modal box is displayed and my form is there. You may note that I am passing in a 'ta' parameter - this is because I have several ckeditors on the page and I need to know which one to put the canned reply in.

Now when I click "Submit" on the canned_responses partial, it posts to "/activities/load_canned_response" which is correct. Here is an exert from the log:

  Processing by ActivitiesController#load_canned_response as JS
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"P7esZjo89RtMawHrzF+Qn3mfPjMZ57s9wWbsxm+aKWI=", "canned_id"=>"1", "ta"=>"task", "commit"=>"Select"}

load_canned_response.js.erb contains the following:


The issue is that "hello" is never displayed. In fact I can type anything in the file and nothing happens.

I just cannot quite re-connect these parts correctly as I could in rails2.

Can someone please point me in the right direction? I have been looking at this for days now... Thanks!

Last edited by ryanshackintosh (2011-04-27 05:38:47)