Polymer 1.0 - injectBoundHTML() alternative -
what's polymer 1.0 equivalent injectboundhtml()?
(i.e. appending html strings nodes within polymer element , having data bindings resolve)
a jsbin example - http://jsbin.com/jufase/edit?html,output
edit: don't have enough cred accept own answer yet, should down below somewhere. tl;dr - use "dom-bind" templates
although techknowledgey pointed out it's not supported yet. following seems trick.
function injectboundhtml(html, element) { var template = document.createelement('template', 'dom-bind'); var doc = template.content.ownerdocument; var div = doc.createelement('div'); div.innerhtml = html; template.content.appendchild(div); while (element.firstchild) { element.removechild(element.firstchild); } element.appendchild(polymer.base.instancetemplate(template)); }
if html parsed use "doc.importnode(sourcenode, true);" instead of getting/setting innerhtml.
Comments
Post a Comment