Don Mapp wrote in post #956253:
> Does anyone knows how to do an observe field using Prototype in Rails
> 3. An example would be useful as I am very weak programming in Ajax.

Prototype
-------------------
document.observe("dom:loaded", function() {
  $('foo').observe('click', function(event) {
    this.setStyle({backgroundColor: 'blue'});
  });
});

jQuery
-------------------
$(document).ready(function() {
  $('#foo').click(function() {
    $(this).css("backgroundColor", "blue");
  });
});

Notice that this begins observing the "click" event on the element with 
id="foo" attribute. Also, notice that it waits for the DOM to fully load 
before attaching the event listener.

If you want to observe something other than "click" the just replace 
that with the event you want to observe (e.g. "change").

-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to