Created
November 2, 2012 22:24
-
-
Save stlsmiths/4004716 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> | |
<html> | |
<head> | |
<title>DT Destroy</title> | |
<meta http-equiv="content-type" content="text/html; charset=utf-8"> | |
</head> | |
<body class="yui3-skin-sam"> | |
<button id="btnRebuild">Rebuild it!</button> | |
<button id="btnDestroy">Destroy it!</button> | |
<br/> | |
<div id="dtable"></div> | |
<script src="http://yui.yahooapis.com/3.7.3/build/yui/yui-min.js"></script> | |
<script> | |
YUI().use("node","datatable",function(Y){ | |
var dt; | |
function destroyDT(){ | |
if(dt) { | |
dt.destroy(); | |
dt = null; | |
} | |
} | |
function buildDT(){ | |
if(dt) return; | |
var somedata = [ | |
{rid:10, rtext:'text A', col3:12345 }, | |
{rid:13, rtext:'text B', col3:12345 }, | |
{rid:15, rtext:'text C', col3:12345 }, | |
{rid:17, rtext:'text D', col3:12345 }, | |
{rid:19, rtext:'text E', col3:12345 } | |
]; | |
dt = new Y.DataTable({ | |
columns: [ 'rid', 'rtext', 'col3' ], | |
data: somedata | |
}).render('#dtable'); | |
} | |
buildDT(); | |
Y.one("#btnDestroy").on("click", destroyDT); | |
Y.one("#btnRebuild").on("click", buildDT); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment