0

I have the following checkbox with a class on it, for future use

.class{onClick: "doSomething()"}= check_box @var, :var

But there's a problem. Let's pretend |AAAA| is the buton, if i click on the ==.. it still triggers doSomething().

|AAAA| ====================

I tryied with

display: block 

in css but it doesn't work

Thanks

0

3 Answers 3

1

That's because both the label and input area are enclosed in the .class.

Instead, specify via js that you only want the checkbox input to trigger your JS action, and not the label.

= check_box @var, :var, id: 'my-id'

Then:

:javascript

   $("input#my-id").click(function() {
       doSomething();
   });
1

What is generated html?

Looks like you've set onClick handler to outer div, not to the checkbox.

( I assume you have reasons to use inline javascript instead on unobtrusive one)

1

There may be 2 reasons this:

1: You have a label tag around the checkbox as well as element containing ==================== (As you said in the question )

2: You may not have given the class to checkbox, rather it is bound to another element that contains checkbox.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.