Skip to content

Commit

Permalink
Added special handling for data fields that are jQuery objects; these…
Browse files Browse the repository at this point in the history
… are converted to HTML (using an outerHTML hack) instead of just passing them in as [Object object].
  • Loading branch information
kpozin committed Jan 13, 2011
1 parent f9b00c8 commit d9d5faf
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions jquery.tmpl.js
Original file line number Diff line number Diff line change
Expand Up @@ -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("<div>").html(datum).html();
newItem.data[propName] = datum;
}
}

if ( options ) {
jQuery.extend( newItem, options, { nodes: [], parent: parentItem });
}
Expand Down

0 comments on commit d9d5faf

Please sign in to comment.