Click checkboxes

4 views
Skip to first unread message

Joe Gaudet

unread,
Sep 12, 2011, 2:49:05 PM9/12/11
to lebow...@googlegroups.com
Hey,

So I've got the standard SC.Checkbox controls embedded in my template views like so:

{{SC.Checkbox id="student-visible" }}

And I'd like to invoke a click event on the checkbox.

I figured it would work something like:

module SC
module Views
class TemplateView < Lebowski::Foundation::Views::View
representing_sc_class 'SC.TemplateView'
end


class Checkbox < TemplateView
representing_sc_class 'SC.Checkbox'
end
end
end

# test runner
include SC::Views
ProxyFactory.proxy TemplateView
ProxyFactory.proxy Checkbox


// assume some app loading cruft that works already
student_visible = @app["#student-visible", Checkbox]
student_visible.click()

The issue I am having is routing that click event to the actual SC.Checkbox, I've tired selecting it with core query and invoking mouseUp which doesn't seem to work for a variety of reasons as I try different things.

Any thoughts would be great.

You can also find my on skype as joegaudet :)

.joe

MikeC

unread,
Sep 14, 2011, 1:51:40 PM9/14/11
to lebowskifw
Hey Joe,

Since you are using the SC.Checkbox, there is already a proxy for it
that handles all the necessary actions to properly click the checkbox.
So instead of doing Checkbox < TemplateView, simply access the
checkbox as a child view from the parent template view. Lebowski will
return an instance of the Lebowski::Foundation::Views::CheckboxView
class.

-Mike

Joe Gaudet

unread,
Sep 14, 2011, 2:11:08 PM9/14/11
to lebow...@googlegroups.com
Are you sure the sc.checkbox will do the same stuff as the sc.checkboxview ?


.joe

----------------------------
Joe Gaudet
778.994.4846

MikeC

unread,
Sep 14, 2011, 4:57:33 PM9/14/11
to lebowskifw
Hey Joe,

Sorry about that. Too many late nights working is starting affect my
ability to concentrate in the morning :P.

In any case, you were referring to SC.Checkbox, not SC.CheckboxView.
The difference between the two is that when the SC.CheckboxView is
rendered (v1.5+), it's not using an input field, but, instead, it's
just rendering with spans and divs and monitoring when those elements
are clicked. SC.Checkbox on the other hand does make actual use of the
input field with type "checkbox", and to actually click it you need to
invoke its click() method.

In Lebowski, when you call the view proxy's click method what it's
doing is raising a mouse down followed by a mouse up event since that
what needs to be done for SC.CheckboxView to correctly react to the
user clicking the view. Therefore, for the SC.Checkbox, you instead
need to instead call the proxy view's basic_click method and that will
call the input field's click method. So you just need to do the
following so long as your base TemplateView class is inheriting the
base View class:

student_visible.basic_click

That should do the trick :).

Again, my apologies for mixing up in what you were referring to.

-Mike

On Sep 14, 11:11 am, Joe Gaudet <joseph.gau...@gmail.com> wrote:
> Are you sure the sc.checkbox will do the same stuff as the sc.checkboxview ?
>
> .joe
>
> ----------------------------
> Joe Gaudet
> 778.994.4846
>
Reply all
Reply to author
Forward
0 new messages