开发者

browser displays the javascript code instead of html page in rails

开发者 https://www.devze.com 2023-01-12 11:42 出处:网络
I got a weird problem, here is the snip开发者_开发技巧pet of my code, View 1: <%= javascript_include_tag :defaults %>

I got a weird problem, here is the snip开发者_开发技巧pet of my code,

View 1:

 <%= javascript_include_tag :defaults %>
 <% remote_form_for (@group, :group, :url => { :action => 'addgroup' }, :update => 'activitypage') do |form| %>

<%= submit_tag "Add!", :class => "submit" %>  
<% end %>

Method 'addgroup',

   def addgroup
    ##<some code here>
    render :update do |page|
    page.replace_html ('activitypage', :partial => 'vindex')
    page[:activitypage].visual_effect :highlight
    return

View 2, _vindex.html_erb

<h1>Group</h1>

<%= javascript_include_tag :defaults %>

I got here

The browser displayed the javascript code as below instead of the html content,

try { Element.update("activitypage", ""); $("activitypage").visualEffect("highlight");....

What is the possible wrong in the code above? Thanks,


Is your partial view named '_vindex.html_erb'? Have you tried renaming it to '_vindex.html.erb' - Rails may not be treating it as HTML (or as an ERB file, for that matter) - which may be the cause of your issue.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号