Currently the posts are filtered by: jquery
Reset this filter to see all posts.

Category: Javascript
Date: 2011-01-05 23:35

Fix jQuery .replaceWith() method to perform in IE8

This article applies to jQuery 1.4.4

The jQuery .replaceWith() method replaces a DOM-element and all of its children by another DOM-element. This function is ideal for use in Ajax applications.

The .replaceWith() method however internally uses the jQuery .remove() method which in Internet Explorer can be dramatically slow. There is a tric however to improve this performance radically by emptying the DOM-element first before removing it. 

It enhanced my performance in IE at least 10 times!

Here's the line:

jQuery(selector).empty().replaceWith(newContent);

back

Category: Javascript
Date: 2010-08-27 15:04

Show jQuery tabs promptly

jQuery tabs are just fabulous!

But if you have a lot of content then you might see your tabs being built up when jQuery applies them.

Here's the solution. Just hide the tabs HTML element initially:

<div id="my_tabs" style="display:none;">

Then use the following jQuery Tabs Event to display them when they are ready:

$('#my_tabs').tabs({ 
  show: function(event, ui) 
  {jQ(event.target).not(':visible').show();}
});

By using jQuery's .not(:visible) filter method show() is executed only once.

back