-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
More concisedom_node
and ref
handling for jquery
#62
Comments
Seems odd that
ie just be explicit? |
cause I hate typing but perhaps these are obscure enough to warrant the extra typing? |
how about |
That sounds great @catmando I will remember that :-) |
so I went around and around on this. In the end I am leaving then there is a the Together you can then say: Meanwhile So you could then say You can also say Finally there is a
Summary:
|
dom_node
and ref
handling for jquery
Summary: In order to get a reference to a component add the special DIV(ref: ->(node) { puts "Hey my inner text is #{`#{node}.innerText` }) { "ho ho ho" }
# puts `ho ho ho` to the console Because often you want to save the node in an instance variable the # @the_div will contain the dom node of the div once the `DIV` has been mounted.
DIV(ref: set(:the_div)) { "click me" }.on(:click) { alert("I said #{`#{@the_div}.innerText`") }
# alerts `click me` If you are using jQuery you can access the jQuery API though the global DIV(ref: set(:the_div)) { "click me" }.on(:click) { alert("I said #{jQ[@the_div].text}") }
Finally if you are using jQuery you can replace the DIV(ref: set_jq(:the_div)) { "click me" }.on(:click) { alert("I said #{@the_div.text") } |
currently you can grab a components ref mapped to jquery using the
dom
keyword:INPUT(dom: set(:_input) ... )
it works just like
ref
, but the resulting value is wrapped by jQuery.however if you say
self.dom_node
you get your own ref, and if you want jQuery you sayDOM[dom_node]
Seems not very symmetrical.
I am suggesting we do something like this:
dom
keyword -> jQuery wrapped referenceref
keyword -> referenceself.dom
-> jQuery wrapped reference to selfself.ref
-> straight dom reference to self.and that is the problem ... its sort of backwards.
So alternative proposal:
dom
keyword is synonym forref
jq
keyword isref/dom
wrapped by jquerylikewise
self.dom
is ref to yourself andself.jq
is your self wrapped by jqueryAny other ideas for a pair of names that could be used consistently in both places?
The text was updated successfully, but these errors were encountered: