English 中文(简体)
更新一个基于另一个(铁路)的选定箱子
原标题:updating a select box based on another (Ruby on Rails)

我需要一个更完整的实例,说明如何根据在Rubu关于铁路的第二种选择箱的结果更新一个选定的箱子。 我问到,这已经是here。 我通过该张贴的反馈阅读了,但没有任何幸运的信号,我已经尝试了几个小时。 任何人都知道一个更好(更完整)的例子?

问题回答

通常用 Java字处理。 我没有特别享受ding本,因此我申请的是使用一种表格“观察器”(一种铁路助手,利用Prototype Javascript的图书馆来观察您的表格,以便进行投入变化),并根据美国宇宙航空研究开发机构呼吁的结果,更新了含有第二盒子的超文本中的数字四。 自美国宇宙航空研究开发机构与我的服务器会谈以来,我可以书写鲁比的任意复杂逻辑,使新的超文本化。

例:

#goes in view
<%= Code to render the first list box. %>
<%= render :partial =>  second_list_box_partial , :locals => {:selected = insert_magic_here } %>

<%= observe_field(:first_list_box,
    :url => { :action => :second_box_ajax }),
    :frequency => 0.5,
    :update => :second_list_box_div,
    :with => %Q|  value=  + $( first_list_box ).value;   |
    %>

#goes in controller
 def second_box_ajax
   first_box_value = params[:value]
   #magic goes here
   @selected = #more magic
   render :partial =>  second_list_box_partial , :locals => {:selected => @selected}, :layout => false
 end

 #goes in partial
 <div id="second_list_box_div">
   Actual code to render list box goes here.
 </div>




相关问题
rails collection_select vs. select

collection_select and select Rails helpers: Which one should I use? I can t see a difference in both ways. Both helpers take a collection and generates options tags inside a select tag. Is there a ...

SSL slowness in EC2

We ve deployed our rails app to EC2. In our setup, we have two proxies on small instances behind round-robin DNS. These run nginx load balancers for a dynamically growing and shrinking farm of web ...

Auth-code with A-Za-z0-9 to use in an URL parameter

As part of a web application I need an auth-code to pass as a URL parameter. I am currently using (in Rails) : Digest::SHA1.hexdigest((object_id + rand(255)).to_s) Which provides long strings like : ...

RubyCAS-Client question: Rails

I ve installed RubyCAS-Client version 2.1.0 as a plugin within a rails app. It s working, but I d like to remove the ?ticket= in the url. Is this possible?

activerecord has_many :through find with one sql call

I have a these 3 models: class User < ActiveRecord::Base has_many :permissions, :dependent => :destroy has_many :roles, :through => :permissions end class Permission < ActiveRecord::...

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml

Text Editor for Ruby-on-Rails

guys which text editor is good for Rubyonrails? i m using Windows and i was using E-Texteditor but its not free n its expired now can anyone plese tell me any free texteditor? n which one is best an ...

How to get SQL queries for each user where env is production

I’m developing an application dedicated to generate statistical reports, I would like that user after saving their stat report they save sql queries too. To do that I wrote the following module: ...

热门标签