wrap only seems to work on dom elements!

wrap only seems to work on dom elements!


I'm not sure whether this is just me but I was trying to use the wrap
functions to enable users to easily change the markup for a plugin. I
was trying this (simplified):
var buttons='<li>one</li><li>two</li>';
var $$box = $(opts.parent.append('<div class="msgbox"><div
class="title">' + opts.title + '</div></div>'));
$$box.find('div.title')
.after($(buttons).wrapAll('<div class="anything"><ul class="buttons"></
ul></div>'));
The idea being that the user can add custom wrap markup around various
bits and bobs. It works if I add the various objects to the dom but
not document fragments.
Am I missing something or does wrap only work on the dom? Would it be
possible to support wrap on fragments?