#682 bug
Peter Pastrnak

Events not registered on inserted elements on IE7

Reported by Peter Pastrnak | May 19th, 2009 @ 01:31 PM | in After 1.7

It seems, that IE7 does not register f.e. 'onclick' events of inserted elements. The reason is most probably in function '_getContentFromAnonymousElement', that is used in the 'Element.insert' function.

_getContentFromAnonymousElement creates a container 'div' element, that does not have the context of the 'document.body', so IE7 is most probably not able to find the javascript functions used in the 'onclick' events.

One working workaround is to add the container to the document body, before setting the innerHTML...

New function could look like this:

Element._getContentFromAnonymousElement = function(tagName, html) {
  var div = new Element('div'), t = Element._insertionTranslations.tags[tagName];
  document.body.appendChild(div);

  if (t) {
    div.innerHTML = t[0] + html + t[1];
    t[2].times(function() { div = div.firstChild });
  } else div.innerHTML = html;

  document.body.removeChild(div);
  return $A(div.childNodes);
};

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

The Prototype JavaScript library.

Shared Ticket Bins

Attachments

Pages