JSFiddle - React, Tailwind, and code Playground
HTML
<link rel="stylesheet" href="http://www.jeasyui.com/easyui/themes/default/easyui.css">
<script src="http://www.jeasyui.com/easyui/jquery.min.js"></script>
<script src="http://www.jeasyui.com/easyui/jquery.easyui.min.js"></script>
<div id="mydiv">
</div>
<template id="mytemp">
<input id="text1">
<input id="text2">
<input id="combo1">
</template>
JavaScript
// show HTML5 templates.
function showfrag(src,tgt) {
tgt = tgt || $('#_fragments_');
var content = src[0].content;
tgt.append(document.importNode(content, true));
//$.parser.parse(tgt);
$(tgt).children().each(function(){
parseObject(this);
})
src.remove();
}
var conf = {
text1: {
type: 'textbox',
value:'xxxx',
onChange:function(nv){
console.log(nv);
}
},
text2: {
type: 'textbox',
value:'yyyyyy',
onChange:function(nv){
console.log(nv);
}
},
combo1: {
type: 'combobox',
data:[
{value:'y',text:'YES'},
{value:'n',text:'NO'}
],
onSelect:function(rec){
console.log(rec.value);
}
}
}
function parseObject(t){
var options = $(t).data('options') || {};
var cls = options.easyui;
if (cls) $(t)[cls](options);
}
$(function(){
$(document).bind('DOMNodeInserted', function(e){
var target = e.target;
if(!target) return;
var id = $(target).attr('id');
if(!id) return;
var obj = conf[id];
//if( !$(target).attr('type')) return
if (!obj.type) return;
$(target).data('options', $.extend({}, conf[id], {
easyui: obj.type
}));
});
// on-demand render the template
setTimeout(function(){
showfrag($('#mytemp'),$('#mydiv'));
},2000);
});