Re: Observe field with jquery in Rails 3.1

Bill Walton
Wed, 11 Jan 2012 18:20:41 -0000

Hi Hans,

On Wed, Jan 11, 2012 at 10:35 AM, Hans
<Hans.Marmolin-6LjvI5LOC4niH4Lt12DN6A@public.gmane.org>
wrote:
> I tries to observe a change  in a field  with jquery in Rails 3.1 in
> order to be able to implement  two cascading select boxes.
> A a first step I just try to observe a click in a div using jquery
> I have the following function in a .js file that is loadedin the head
> section (fieldset is the id of a div) and is displaying a view with
> the div fieldset
>
> $(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

Try giving it an id of a different name.  My guess is that jquery is
''confused'' by your use of ''fieldset'' as an
id because it is also a tag
name.

HTH,
Bill

--
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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com.