[jQuery] Re: Weird IE behavior - need help
thanks again, the thing with the each-scoped functions was really new to me. I'm really waiting for johns book :) the reason for the jquery unlike class string manipulation was the weired behavior and my thought that multiple css changes can produce the slowdown effect. i will change it back to the addClass... removeClass... functions soon, because my solution is only unrecognizable nanosecs faster. the setTimeout trick did the real magic... stefan flick
[jQuery] Re: Weird IE behavior - need help
No need to have two versions of function arguments. The setTimeout( ..., 0) fires directly after (or extremely soon after) the function finishes and it will work for all browsers. Because you don't need separate functions you can just include the functions in the each scope and so have access to the correct row (r). You have a very compact coding style, which is fine though rather difficult to quickly understand :). I've rewritten things in a more jQuery-style. I replaced your constants with the actual strings as it was easier to follow. You can, of course, put the constants back in: rows.each( function() { var r = $(this); var over = function() { if ( r.is('.rws') ) // selected r.removeClass('rws').addClass('rwsh'); else r.addClass('rwh'); }; var out = function() { if ( r.is('.rwsh') )// selected + highlighted r.removeClass('rwsh').addClass('rws'); else r.removeClass('rwh'); }; r.hover( function() { setTimeout(over, 0) }, function() { setTimeout(out, 0) } ); }); Karl Rudd On 6/7/07, devsteff [EMAIL PROTECTED] wrote: THATS IT! thanks a lot! it was a little bit tricky for me to pass the row object to the trHigh/ trLow functions, because when triggered by a timeout this didn't point to the row (the event target) but to the window object :(. so i must implement a browser switch :( my code looks now like: registration: : : if(jQuery.browser.msie){ rows.each(function(){ var r=$(this); r.hover( function(){setTimeout(function(){trHigh(r);},0);}, function(){setTimeout(function(){trLow(r);},0);}); }); }else rows.hover(trHigh,trLow) : : and the handler functions: var trHigh=function(o){ var r=oo[0]?o[0]:this;//o can also be the event in FF var c=r.className; if(c.indexOf(CSS_S)-1){ c=c.replace(RCSS_S,); c+= +CSS_SH; }else c+= +CSS_H; r.className=c; }; var trLow= function(o){ var r=oo[0]?o[0]:this; var c=r.className; if(c.indexOf(CSS_S)-1){ c=c.replace(RCSS_SH,); c+= +CSS_S; }else c=c.replace(RCSS_H,); r.className=c; }; is there a more elegant way to pass the original event target to an function wich is called via setTimeout?? regards, stefan flick On 6 Jun., 01:56, Karl Rudd [EMAIL PROTECTED] wrote: Regarding the document.execCommand(BackgroundImageCache, false, true), the first entry in a Google search for BackgroundImageCache turns up this: http://misterpixel.blogspot.com/2006/09/forensic-analysis-of-ie6.html As to the slowing tracking, it looks like IE has a bit of a pause between the change in className and actually rendering the change to screen. I've just optimised a similar piece of code in project and this is what I've come up with: $('table tr').each( function() { var row = $(this); row.hover( function() { setTimeout( function() { row.addClass('hover'); }, 0 ); }, function() { setTimeout( function() { row.removeClass('hover'); }, 0 ); } ); }); Somehow using the setTimeout bypasses, or shortens, the rendering delay. Karl Rudd On 6/6/07, devsteff [EMAIL PROTECTED] wrote:
[jQuery] Re: Weird IE behavior - need help
Part of the problem (the flickering cursor) is due to IE doing it's cache checks on changes in background images. To fix that put this at the top of one of your jQuery scripts: if ( $.browser.msie ) document.execCommand(BackgroundImageCache, false, true) Karl Rudd On 6/5/07, devsteff [EMAIL PROTECTED] wrote: Hi jQuery community, I've written a complex jQuery table plugin wich supports different selection models (single, multiple, exclusive), nested/hierarchical tables (like a tree) etc. Everything works well, but now - while the application goes testing by some clients - I stumbled by an very ugly performance issue in IE. The problem appers only on IE machines - very remarkable on slower lowend hardware. Anyway FF and Mozilla is fine at all. For an easier problem tracking I've extracted the problematic code from the plugin and provide a simple test example with the embedded plugin code. Please follow the next steps and try to retrace the problem. * Load the the test page from http://members.inode.at/396869/jq/ into your browser * Try moving the mouse (quick) over the table and watch the performance (highlight row follows mouse) and the mouse pointer type is usually the pointer * Now click ***somewhere*** in the page - doesn't matter if on the table or on the body background! * Try moving the mouse over the table again and watch the performance and the mouse pointer now... Recognize it? The highligtning is now very bumpy und the mouse pointer toggles rapidly between the hour glass and the pointer. There is NO event registration by my plugin on the page nether on the background. What happens after clicking on the page? What is the reason for the slow down of the browser? What kind of code is executing after the click? I don't have any idea... Is it a jQuery, a IE browser or a plugin problem? My config Thinkpad T60,Windows XP SP2, IE6.0.2900.2180.xpsp. 050928-1517. As jQuery version i used 1.1.2 and the latest 1.1.3b. Same effekt. The length of the table is not an issue. Effekt also happens with 10 rows... Thanks in advance for any hint, Stefan Flick
[jQuery] Re: Weird IE behavior - need help
wow thanks! the mouse cursor flickering is gone. but why is the cache checking activatetd AFTER the first click on the page? where can i find some more information of document.execCommand(...) do you have a link? i found some but, the bumpy slow motion tracking still ruins my nerves... On Jun 5, 3:36 pm, Karl Rudd [EMAIL PROTECTED] wrote: Part of the problem (the flickering cursor) is due to IE doing it's cache checks on changes in background images. To fix that put this at the top of one of your jQuery scripts: if ( $.browser.msie ) document.execCommand(BackgroundImageCache, false, true) Karl Rudd On 6/5/07, devsteff [EMAIL PROTECTED] wrote: