RJS错误"对象不支持此属性"在元素的更新 [英] RJS error "object doesn't support this property " on element update

查看:133
本文介绍了RJS错误"对象不支持此属性"在元素的更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下的code控制器。 我填充一个下拉框,动态的基础上,从另一个下拉框中选择。

I have the following code in the controller. I am populating a drop down box dynamically based on the selection from another drop down box.

def  update_releases 
  project = Project.find(params[:project_id]) 
  releases = project.releases
  puts "releases==#{releases}" 
  render :update do |page| 
  page.replace_html 'releases', :partial => 'releases', :object => releases 
end 

查看code:

-form_tag reports_path(report_type=1),:method => :get, :multipart => true ,:id => "filter" do  
%table.grid.full
%tr      
  %td.grid.full_panels{:style => "width: 20%"}
    Project:
  %td.grid.full_panels{:style => "width: 20%"}
    //= select_tag "projects",options_from_collection_for_select(projects,"id","name",params[:projects]),{:onchange => "#{remote_function(:url  => {:action => "update_releases"},:with => "'project_id='+value")}"} 
    = select_tag "projects",options_from_collection_for_select(projects,"id","name",params[:projects]), :class => "update_releases"


  %td.grid.full_panels{:style => "width: 20%"}
    Releases:
  %td.grid.full_panels{:style => "width: 20%"}
    <div id="releases">
    = render :partial => 'releases', :object => @releases
  %td.grid.full_panels{:style => "width: 20%"}
    Cycles:
  %td.grid.full_panels{:style => "width: 20%"}
    <div id="cycles">
    = render :partial => 'cycles', :object => @cycles

%tr      
  %td.grid.full_panels{:style => "width: 20%"}
  %td.grid.full_panels{:style => "width: 20%"}
  %td.grid.full_panels{:style => "width: 20%"}
    =submit_tag "Submit"

= javascript_include_tag "pages/ic"

谐音code:      = select_tag版本,options_from_collection_for_select(发行版中,ID,名,则params [:版本])

partials code : = select_tag "releases",options_from_collection_for_select(releases,"id","name",params[:releases])

jQuery的:       //改变版本下拉基础上,项目的selction降下来了。

Jquery: //change the releases drop down based on the selction of the projects drop down.

$('.update_releases').live("change", function(){
  $.ajaxSetup({beforeSend: function(xhr) {xhr.setRequestHeader("X-CSRF-Token", $("meta[name='csrf-token']").attr("content")); }});
  var project_id=($(this).val());
  $.post('/reports/update_releases', {project_id: project_id});
 return false;
})

我得到一个错误元素不支持chaning的选择,在下拉框中该财产弹出。请帮我在这里。

I am getting an error element doesn't support this property" as a pop up on chaning the selection in the drop down box. Please help me out here.

推荐答案

作为简单的解决方法尝试使用此code。在控制器:

As simple workaround try to use this code in controller:

respond_to do |format| 
  format.js render :partial => 'releases', :locals { :releases => releases }
end

releases.js.haml

   $('#releases').html('#{render :partial => '<some_old_html_partial>', :locals => {:releases => releases}}')

这篇关于RJS错误&QUOT;对象不支持此属性&QUOT;在元素的更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆