View Single Post
Old 10-03-2012, 11:32 PM   PM User | #5
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,567
Thanks: 62
Thanked 4,058 Times in 4,027 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
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; 
};
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote
Users who have thanked Old Pedant for this post:
Piece Of Meat (10-04-2012)