Richard,
Thanks for your reply.
It is neat but it leaks memory on IE.
While the following not:
$.fn.replaceWithAndReturnNew = function(html){
var div = document.createElement('div');
var replaced = this[0];
replaced.parentNode.replaceChild(d
This one is slightly better altough not in jQuery style:
$.fn.replaceWithAndReturnNew = function(html){
var elm = $(this)[0].cloneNode(false);
$(this).after(elm).remove();
elm.innerHTML = html;
return $(elm);};
On Sep 20, 9:31 am, tchvil <[EMAIL PROTECTED]> wrote
$.fn.replaceWithAndReturnNew = function(htmls){
var replacer = $(htmls);
$(this).replaceWith(replacer);
return replacer;
};
- Richard
On Sat, Sep 20, 2008 at 3:31 AM, tchvil <[EMAIL PROTECTED]> wrote:
>
> Thanks a lot for your replies.
> Ok, I guess there are good reasons to return the rep
Thanks a lot for your replies.
Ok, I guess there are good reasons to return the replaced object.
Now my question becomes... is there a better jQuery way of doing this
quite ugly thing:
$.fn.replaceWithAndReturnNew = function(htmls){
var replaced = $(this)[0];
var div = document.c
On Wed, Sep 17, 2008 at 4:58 PM, Karl Rudd <[EMAIL PROTECTED]> wrote:
>
> Err remove() is chainable. It doesn't "return a DOM element", it
> "keeps hold" of the elements that it was called to remove from the
> DOM. So it acts just like replaceWith().
>
> There was a debate in the early stages of j
Sorry, I missunderstood the initial (and subsequential) posts.
The present behavior (return the initially matched element) is the
correct one. That's what I'd expect and it matches the behavior of
remove(), append(), etc.
Don't file any bug report :)
Thanks Richard for pinging me about this.
--
I think this is a bug, I'd expect replaceWith to return the old set,
just like append/etc.
Can you (tchvil) file a bug with a test case ? put it under core,
assigned to me.
Thanks
--
Ariel Flesler
http://flesler.blogspot.com/
On Sep 17, 8:04 am, "Richard D. Worth" <[EMAIL PROTECTED]> wrote:
> O
Err remove() is chainable. It doesn't "return a DOM element", it
"keeps hold" of the elements that it was called to remove from the
DOM. So it acts just like replaceWith().
There was a debate in the early stages of jQuery about whether or not
methods (not including the base $/jQuery function) tha
On Wed, Sep 17, 2008 at 6:58 AM, Karl Rudd <[EMAIL PROTECTED]> wrote:
>
> Nah, it's not a bug.
>
> replaceWith( content ) Returns: jQuery
> Replaces all matched elements with the specified HTML or DOM elements.
> This returns the JQuery element that was just replaced, which has been
> removed fro
Nah, it's not a bug.
replaceWith( content ) Returns: jQuery
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
( http://docs.jquery.com/Manipulation )
It's like doing a remove(), fol
This sounds like a bug to me. Better raise it on the jQuery Dev list:
http://groups.google.com/group/jquery-dev/
- Richard
On Tue, Sep 16, 2008 at 4:58 AM, tchvil <[EMAIL PROTECTED]> wrote:
>
> Hi,
> replaceWith returns the JQuery element that was just replaced.
>
> In the example below:
> $( '
11 matches
Mail list logo