also:

$capt[getForm(this).adapter.render_context.allow_html = 'html'](this.caption);

needs to be replaced with simply:

$capt.html(this.caption);