Forgot part deux..
counter.down('input.counter').observe("focus", function(event){
Event.element(event).blur(); });
although I tested in IE6 and it seems the elements aren't extended so I
had to do this:
$($(counter).down('input.counter')).observe("focus",
function(event){ Event.element(event).blur(); });
Now what the hell is that? Surely prototype can extend elements itself
somewhere along the line. Wrapping each element in $() just looks
silly. What good is chaining if you can't do it properly?
Colin
David Dashifen Kees wrote:
Wow. Pastie rocks: http://pastie.caboo.se/47296
So, you can see in that code on line #4 an attempt to force the counter
to observe focus events. Currently, it's just an anonymous call to the
alert("hi") function but it never fires. I left the CSS out of it, but
suffice it to say that the background positioning is used to control
the look of the div.button elements so that they have an off, over, and
pressed states like a button. Using them provides the basic
functionality of a numeric counting widget like you can find in various
incarnations (e.g., flash, python, etc.) but is lacking for web sites.
Not sure if I really need the code to work; it was just an exercise.
So, the needs are this: (1) to determine why, in the code linked
above, the focus action is never fired for the counter elements and (2)
once the event is firing, change it from an alert event to simply blur
the focused field.
Thanks for taking a peak!
-- Dash --
Colin Mollenhour wrote:
Will the readonly attribute not work?
<input type="text" readonly />
Or in JS, I think you can do element.readonly="readonly" but I'm not
sure if that is the correct way offhand.
I don't know why your focus event isn't working, post more code (use
pastie for large quantities) or a minimalistic test page if necessary.
Colin
David Dashifen Kees wrote:
So, I want to blur an input field when it is focused. I can easily add
to the html for the input field(s) that require
it, but I've been trying to wean myself off of inline function calls
little-by-little as I learn more about the prototype.js Event.observe()
and related behavior. But, I haven't been able to use Event.observe to
fire a function on a focus event. I've tried to do things like
Event.observe($("blur_me"), "focus", function() { alert("hi") }) and the
alert doesn't happen. Is there something I'm missing?
-- Dave --
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
|