Rails 2.3.5 - > Rails3问题:observe_field

时间:2011-05-04 08:30:46

标签: ruby-on-rails ruby-on-rails-3

在Rails 2.3.5应用程序中,我有:

observe_field:searchtype,:url => {:action =>'set_search_type'},:with => “'search_type ='+ value”

这在Rails3中不再有效。实现这个的新方法是什么?

谢谢,

1 个答案:

答案 0 :(得分:3)

JQuery模拟解决方案:

$(document).ready(function() {
  $("#searchtype").bind("blur", function() {
    var url = '/set_search_type'; //your real url "??/set_search_type"
    var data = {search_type: $(this).val()}; // hash of input names and values for sending to server
    $.get(url, data, // make ajax request
     function(html) { // function to handle the response
    });
  });
});

How to convert this observe_field to jquery

Rails observe_field using jQuery