From d9d5fafc7cfd45ecd92346c748ac37eeb7380450 Mon Sep 17 00:00:00 2001 From: Konstantin Pozin Date: Thu, 13 Jan 2011 10:38:42 -0500 Subject: [PATCH] Added special handling for data fields that are jQuery objects; these are converted to HTML (using an outerHTML hack) instead of just passing them in as [Object object]. --- jquery.tmpl.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/jquery.tmpl.js b/jquery.tmpl.js index c37e764..8594f11 100644 --- a/jquery.tmpl.js +++ b/jquery.tmpl.js @@ -27,6 +27,17 @@ html: tiHtml, update: tiUpdate }; + + var dataProps = Object.getOwnPropertyNames(newItem.data); + for (var i = 0; i < dataProps.length; ++i) { + var propName = dataProps[i]; + var datum = newItem.data[propName]; + if (datum && datum instanceof jQuery) { + datum = jQuery("
").html(datum).html(); + newItem.data[propName] = datum; + } + } + if ( options ) { jQuery.extend( newItem, options, { nodes: [], parent: parentItem }); }