javascript - IE7 loses parameters in event handler function - prototype.js -
i have bunch of elements on page class of "product". want attach event handler each one, on hover tooltip shown. following code working fine in chrome, firefox, safari , ie8+, not ie7:
function init() { $$('.product').each(function(elm) { var id = elm.id; var name = new element('div', {'class': 'title'}).update(products[id].name); var desc = new element('div').update(products[id].desc); var content = new element('div'); content.appendchild(name); content.appendchild(desc); elm.observe('click', function() {showtooltip(content)}); elm.observe('mouseover', function() {showtooltip(content)}); elm.observe('mouseout', function() {hidetooltip()}); }); } document.observe('dom:loaded', init); in ie7 first time hover on each element, works fine. but, 2nd time hover on element, "content" variable empty. if replace showtooltip() function simple alert(content.innerhtml), alerts proper html first time, , alert empty every time after.
i tried store content object, , use bindaseventlistener, same result.
anyone have thoughts on causing content not persist in ie7?
thanks
i try appending "content" dom instead , pass reference element tooltip, rather 1 in code.
Comments
Post a Comment