Hey Viktor, This syntax is just not supported at the moment.
Use: new Element('div').observe('click', callback); instead. Regards, Tobie On Oct 19, 2:37 pm, Viktor Kojouharov <[EMAIL PROTECTED]> wrote: > This is a really troublesome bug, which is exhibited in IE browsers. > Consider this code: > > new Element('div', {onclick: 'alert(this)'}); > > In every other browser, this will produce a div, that, when clicked, > will alert. In IE, on* events are not registered, since internally > prototype uses setAttribute. setAttribute cannot set these. The only > way such attributes can be registered is in the createElement method > itself. For this reason, I've written a drop-in replacement for 'new > Element' which fixes this issue. I seriously urge you to fix this > issue (by either using the code below, or using your own methods), > otherwise `new Element' will not create elements that are identical > throughout all browsers. > > That being said, this is my drop-in replacement: > > (function() { > var element = this.Element; > this.Element = function(tagName, attributes) { > attributes = attributes || { }; > tagName = tagName.toLowerCase(); > var cache = Element.cache; > if (Prototype.Browser.IE) { > var conflicts = $H(attributes).grep(/(?:name|on\w+)/); > if (conflicts.length) { > var attributeString = ''; > conflicts.each(function (tuple) { > delete attributes[tuple[0]]; > attributeString += tuple[0] + '="' + tuple[1] + '"'; > }); > tagName = '<' + tagName + ' ' + attributeString + '>'; > return > Element.writeAttribute(document.createElement(tagName), attributes); > } > } > if (!cache[tagName]) cache[tagName] = > Element.extend(document.createElement(tagName)); > return Element.writeAttribute(cache[tagName].cloneNode(false), > attributes); > }; > Object.extend(this.Element, element || { }); > }).call(window); --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Prototype: Core" group. To post to this group, send email to prototype-core@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en -~----------~----~----~----~------~----~------~--~---