I'm developing a project on rails and I got a problem on getting the selected item on drop down menu. It works fine on views/applications but when I try to use the same code to get the selected item at the jQuery model dialog box, it doesn't work for me. Can someone explain the problem in this? Can't I use the observe_field on model dialog box?

我正在rails上开发一个项目,在获取下拉菜单上的选定项时遇到了一个问题。它在视图/应用程序上工作得很好,但是当我试图使用相同的代码在jQuery模型对话框中获取所选项时,它对我不起作用。有人能解释一下这个问题吗?我不能在模型对话框中使用observe_field吗?

This is my code:

这是我的代码:

        <%= label_tag :Search_by %>
         <select name="search" id="search" >
            <option value="0">Name</option>
            <option value="1">Trainer</option>
            <option value="2">Venue</option>
            <option value="3">Date</option>
         </select>

        <div id="div_to_be_updated" style="float:right">
            <%= render 'layouts/new_search' %>
        </div>

            <%= observe_field 'search', :update => 'div_to_be_updated',
            :url => {:controller => 'events', :action=> 'find' },
            :with => "'is_delivery_address=' + escape(value)" %>                 
        </div>

This is my "find" method in "events" controller:

这是我在“事件”控制器中的“查找”方法:

enter code here
def find
@trainers= Trainer.all
@countries= Country.all

        if ["0"].include?(params[:is_delivery_address])
            render :partial => 'layouts/new_search'
        else if ["2"].include?(params[:is_delivery_address])
            render :partial => 'layouts/venu_search'
        else if ["1"].include?(params[:is_delivery_address])
            render :partial => 'layouts/trainer_search'
        else
            # check element is date range...
            render :partial => 'layouts/date_search'

        end
        end
    end
end

I can't understand the reason for this problem. It works in application.html.erb file but it doesn't work on the jQuery model dialog box.

我不理解这个问题的原因。它在application.html工作。erb文件,但是它不能在jQuery模型对话框中工作。

1 个解决方案

#1


3

I see here that RoR uses Prototype to create 'observable' element in form. If this happens before you create your jQuery modal dialog box (i guess again you use jQuery UI Dialog) it could 'observe' wrong or non existing element.

我在这里看到RoR使用Prototype创建“可观察”元素的形式。如果在创建jQuery模态对话框(我猜您也使用了jQuery UI对话框)之前发生这种情况,它可能会“观察”错误或不存在的元素。

Try creating dialog before observable ergo before RoRs PrototypeHelpers run.

在RoRs原型机运行之前尝试创建对话框。

更多相关文章

  1. jQuery UI对话框调整大小关闭按钮
  2. 最简单jquery.ajax+php例子(对话框显示文本框输入内容),以小见大
  3. 打开后,JQuery ui对话框调整大小
  4. 使用jQuery确认对话框防止上的表单回发
  5. 聊聊css盒子模型
  6. HTML+DIV+CSS零基础快速入门到制作企业站视频课程_18 盒模型[浮
  7. 【转】phpcms-v9中关于模型的理解
  8. thinkphp5 数据库和模型详解 之1 数据库基础
  9. yii2的AR模型对id自动去重的问题

随机推荐

  1. 外行人都能看得懂的机器学习,错过了血亏!
  2. 周末推荐阅读【第二弹】
  3. 从零单排学Redis【白银】
  4. GraphObject继承的类包括:Shape、TextBlo
  5. 从零单排学Redis【黄金】
  6. Linux定时任务邮件信息占盘磁盘
  7. 给女朋友讲解什么是Optional【JDK 8特性
  8. android Android签名证书的sha1值报错 :不
  9. IDA调试修改内存数据
  10. 为什么需要Docker?