| jQuery Plugin - FlyDOM: Create DOM on the Fly |
Since jQuery.com unveiled their new plugin wiki, I went ahead and created a new plugin page for FlyDOM. You can find this page at: http://jquery.com/plugins/project/FlyDOM.
Create DOM elements on the fly and automatically append them to the current DOM obejct
$('#exampleCA').createAppend(
'table', { width: '718px', style: 'border: 2px inset #336699;' }, [
'tr', { className: 'exampleRow' }, [
'td', { align: 'center', style: 'color: white;' }, 'I was created by createAppend()!'
]
]
);
Create DOM elements on the fly and automatically prepend them to the current DOM obejct
$('#exampleCP').createPrepend(
'table', { width: '718px', style: { 'borderWidth': 2, 'borderStyle': 'inset', 'border-color': '#336699' } }, [
'tr', { className: 'exampleRow' }, [
'td', { align: 'center', style: 'color: white;' }, 'I was created by createPrepend()!'
]
]
);
Create DOM elements on the fly using a simple template system, and then append the new element(s) to the end of the calling object.
var json = { text: 'I was created by tplAppend()!' };
var tpl = function() {
return [
'table', { width: '718px', style: 'border: 2px inset #336699;' }, [
'tr', { className: 'exampleRow' }, [
'td', { align: 'center', style: 'color: white;' }, this.text
]
]
];
};
$('#exampleTA').tplAppend(json, tpl);
Create DOM elements on the fly using a simple template system, and then prepend the new element(s) to the beginning of the calling object.
var json = { text: 'I was created by tplPrepend()!' };
var tpl = function() {
return [
'table', { width: '718px', style: 'border: 2px inset #336699;' }, [
'tr', { className: 'exampleRow' }, [
'td', { align: 'center', style: 'color: white;' }, this.text
]
]
];
};
$('#exampleTP').tplPrepend(json, tpl);