View Single Post
Old 10-04-2012, 12:27 PM   PM User | #6
Piece Of Meat
New Coder

 
Join Date: Oct 2012
Posts: 16
Thanks: 3
Thanked 0 Times in 0 Posts
Piece Of Meat is an unknown quantity at this point
Quote:
Originally Posted by Old Pedant View Post
Ummm...as I read that, you are trying to attach the event listeners to those various forms, WHETHER OR NOT the form exists in that page!

So the first one that doesn't exist (which will indeed addform if you are on the edit page?) you get an error and everything stops.

Maybe a simple answer is to ignore any request to set the listener on a null item?

Code:
function attachEventListener(target, eventType, functionRef, capture)
{
  if ( target == null ) { return true; }
  if ( target.addEventListener != null )
  {
    target.addEventListener(eventType, functionRef, capture);
  }
  else 
  {
    target.attachEvent("on" + eventType, functionRef);
  }
  return true; 
};
I didn't try it because i allready mixed edit and index to be the same page and it solved the problam, but i guess you got a point in what you are saying.
Another question to: How can i do that everytime there is a mouseover event in a table, the row which i mouseover on changes its color?

felgall, Thank for your answear but the first eventlistener is working and not the last one so i guess it's not the problem.
Piece Of Meat is offline   Reply With Quote