#14181 closed feature (plugin)
Provide function similar to replaceWith which uses detach rather than remove
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | undecided | Milestone: | None |
Component: | unfiled | Version: | 1.10.2 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
At present replaceWith() always cleans the removed nodes of handlers and data. It would be useful to be able to pass the "keep data" argument remove() accepts, or to have a new function which achieves the same end, similar to detach().
Change History (9)
comment:1 Changed 10 years ago by
Resolution: | → plugin |
---|---|
Status: | new → closed |
comment:2 follow-up: 3 Changed 10 years ago by
Yes, and that's in fact almost exactly the implementation I came up with (it's just the replaceWith() function from the Jquery source but with remove() swapped out for detach()) but it would mean no duplication of code if it were in mainline Jquery, and it's certainly not an obscure request. On the contrary, it's a very-easily-filled gap in functionality. All it'd need is an extra argument to replaceWith() which is passed through verbatim to remove(), and then this could be either documented or undocumented with a separate documented method (just like detach() is a thin wrapper for remove()) which uses this extra argument.
comment:3 Changed 10 years ago by
Replying to bart@…:
Yes, and that's in fact almost exactly the implementation I came up with (it's just the replaceWith() function from the Jquery source but with remove() swapped out for detach())
Yep ;)
but it would mean no duplication of code if it were in mainline Jquery,
It would be a duplication of code in jQuery core library... how would you overload replaceWith? It's a var arg function http://jsfiddle.net/rwaldron/UJQVB/
and it's certainly not an obscure request.
It's not? I've never read encountered this issue or seen it filed here... That's not to say it hasn't been, but I don't really want to search through 5 years of closed tickets.
On the contrary, it's a very-easily-filled gap in functionality. All it'd need is an extra argument to replaceWith() which is passed through verbatim to remove(),
And there it is... again, see: http://jsfiddle.net/rwaldron/UJQVB/
comment:4 Changed 10 years ago by
Ah, true. I guess it would be possible as an optional first boolean argument. I guess that's complicating things.
comment:6 Changed 10 years ago by
Complicating things? Or an optional first boolean? Pretty simple code, just wouldn't be the most intuitive. But again, it could be undocumented and used only internally as with the argument to remove().
comment:7 follow-up: 8 Changed 10 years ago by
Or an optional first boolean?
That is the mistake we'll never make again (the original mistake is in jQuery.extend)
But again, it could be undocumented and used only internally as with the argument to remove().
But you're asking for this api as a public api for you to use...?
Can we move on?
comment:8 Changed 10 years ago by
But again, it could be undocumented and used only internally as with the argument to remove().
But you're asking for this api as a public api for you to use...?
I meant for a separate new documented function to use. Just like (as I've mentioned before) remove() accepts an argument which is undocumented, but which the documented detach() function uses.
Can we move on?
By all means use your time however you like.
Seems like a good plugin
(Untested, but probably works the way you want it to)