Re: Observe field with jquery in Rails 3.1

Robert Walker
Wed, 11 Jan 2012 19:46:00 -0000

Hans Marmolin wrote in post #1040373:
> $(document).ready(function() {
> $(''#fieldset'').bind({
>   click: function() {
>   alert(''Change'');
>     // do something on click
>   },
>   mouseenter: function() {
>     // do something on mouseenter
>   };
> });
>  });
> But nothing happens when I click in the field
> I suspect that I am using jquery  in the wrong way
> I would appriciate any advice !
> Hans

I''d first try a simpler case just to make sure everything is
"wired up"
correctly:

$(function() {
  $(''#fieldset'').click(function() {
alert{"Clicked"); });
});

If this works then you know you''re finding the right HTML element and
correctly binding a "click." Once you''ve confirmed this then
try the
more complex bind syntax.

P.S. I used the shorthand for waiting for the DOM ready event for
simplification & demonstration.

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