Joe McGuckin
Joe McGuckin

Reputation: 71

Rails 2.3.5 -> Rails3 problem: observe_field

In a Rails 2.3.5 app, I have:

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

This no longer works in Rails3. What's the new way to implement this?

Thanks,

Joe

Upvotes: 0

Views: 855

Answers (1)

Sector
Sector

Reputation: 1210

JQuery analogue solutions:

$(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

Upvotes: 3

Related Questions