On Feb 14, 2:28 am, Christophe Porteneuve <[EMAIL PROTECTED]> wrote:
> Hey Raf,
>
> raf a écrit :
>
> > about getting a reproducible case online, but at the moment I don't
> > have access to an externally visible site.
>
> That *would* be the most convenient way for us to dip inside this.
>
> > <tr onclick="my_toggle(event, 'tr', 'pourList', <%= pour.id %>)">
> > which becomes:
> > <tr onclick="my_toggle(event, 'tr', 'pourList', 1)" class="">

An id of "1" is invalid HTML, ID's can't start with a number, though
they can include numbers.  If the ID is the number of the row, you
might consider using the tr's rowIndex property.  Consider also
passing 'this' to the function, that way you get a reference directly
to the TR element that called my_toggle().


> > depending on the id (1, in this case) of the row being clicked.
>
> I wish this were unobstrusive, but that's besides the issue here...
>
> > As for the event argument, I am not running on IE, I am using Firefox
> > 2 on OSX. I read somewhere that this is the most portable way to pass
>
> My bad, it *is* W3C-based.  I must have been dozing...
>
> > the event object to an event handler.I believe I need the other
>
> The thing is, using onclick attributes in your HTML will not pass it on
> IE.  Using any sort of dynamic handler registration (IE's attachEvent,
> W3C's addEventListener, or Prototype's smoothing Event.observe)
> guarantees the event object will get passed.


Ooops - using:

[HTML]
  <tr onclick="foo(event, ...);" ...>

[script]
  function foo(event, ...) {...}

most *is* a good, cross-browser method of passing a reference to the
event object to a function (albeit not so good if you don't like in-
line code, but that's another subject).  When using addEventListener
and addEvent, you have to do things like:

  function foo(e){
    var e = e || window.event;
    ...
  }

to cope with the different event models.  What's more difficult
(though not impossible) to deal with is that the above methods set the
function's this keyword differently in the Gecko and IE models.  The
usual deal is to use the function's call or apply method to set it in
the call so it's the same in both cases (as Prototype.js does).


--
Rob


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to