Re: [jQuery] replaceWith bug in jQuery 1.4?

2010-01-20 Thread Evgeny Bobovik
This is not a bug, if u want to replace data contained on the element, you
can use operator $(element).html('any html or text');

*Email: bobo...@gmail.com
ICQ: 382081663
Skype: evgeny_bobovik

Gk___*


Re: [jQuery] replaceWith bug in jQuery 1.4?

2010-01-20 Thread Nathan Klatt
On Wed, Jan 20, 2010 at 8:43 AM, teknoFX  wrote:
> There appears to be a bug in the jQuery 1.4 implementation of
> replaceWith.  If you try to replace an element with just plain text,
> jQuery removes the element altogether and does not swap in the text.

>From the replaceWith documentation, emphasis mine: "Replaces all matched
elements with the specified HTML or DOM elements. This returns the JQuery
element that was just replaced, *which has been removed from the DOM*."

Nathan


[jQuery] replaceWith bug in jQuery 1.4?

2010-01-20 Thread teknoFX
There appears to be a bug in the jQuery 1.4 implementation of
replaceWith.  If you try to replace an element with just plain text,
jQuery removes the element altogether and does not swap in the text.
It works fine if the text is surrounded by tags.  For example:

this is some text

Doing: $("#foo").replaceWith("hello world") will remove the div and
anything inside it
Doing: $("#foo").replaceWith("hello world") works fine!

As a workaround for the meantime, I am doing this:
x = $("#foo").parent();
$("#foo").replaceWith("hello world");
x.html(x.html().replace(/<[\/]*hack>/g,''));

Any ideas?  Is this a known bug already?

Thanks!

J