[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


[jQuery] Re: trim string

2009-09-15 Thread teknoFX

You could easily just do the following:

cat=["com12", "com1", "cop233", "com1.1", "sap-12-1"];
cat = $.map(cat, function(a){ return a.replace(/[\d\.\-]/g, ""); });

Good Luck!