title: escape_javascript not working properly in Rails
body: <p>I'm having problems with unobtrusive javascript.  In my <code>TwitterAccountController</code> I have:</p>
  
  <pre><code>def unshare
    @twitter_account = TwitterAccount.find(params[:id])
    #@twitter_account.update_attribute(:message_enabled, true)
    respond_to do |format|
      format.html { redirect_to @twitter_account.user }
      format.js  # responds to TwitterAccount/share.js.erb
    end
  end
  </code></pre>
  
  <p>which is what happens when you click a button in my view named "unshare"</p>
  
  <p>the unshare.js.erb that responds is:</p>
  
  <pre><code>var div_name = '&lt;%="div#share_form_#{@twitter_account.id}"%&gt;'
  $(div_name).html("&lt;%= escape_javascript(render(:partial =&gt; 'shared/share', :locals =&gt; {:twitter_account    =&gt; @twitter_account}))%&gt;");
  </code></pre>
  
  <p>It's suppose to switch the button from "unshare" button to "share" button.  But when the "unshare" button is clicked, this is the code generated from escape_javascript:</p>
  
  <pre><code>&lt;form accept-charset=UTF-8 action=/twitter_accounts/1/share data-remote=true method=get&gt;
    &lt;div style=margin:0;padding:0;display:inline&gt;&lt;input name=utf8 type=hidden value=&amp;#x2713; /&gt;
    div&gt;        
    &lt;input name=commit type=submit value=share /&gt;
  form&gt;
  </code></pre>
  
  <p>you can tell the closing tags are messed up, does anyone know the reason for this???</p>
  
  <p>my javascript_include_tag is:</p>
  
  <pre><code>&lt;%= javascript_include_tag 'jquery.min.js', "rails.js", "d3.js","d3.time.js", "raphael.js", "collapse_menu.js" %&gt;
  </code></pre>
  
  <p>the share partial:</p>
  
  <pre><code>&lt;%= form_tag(share_twitter_account_path(twitter_account), :method =&gt; 'get', :remote =&gt; true) do %&gt;
    &lt;%= submit_tag "share"%&gt;
  &lt;% end %&gt;
  </code></pre>