This is an example on how to display all list Templates using JavaScript\ECMAScript Client object model in SharePoint 2010.
You can simple copy and paste the below in HTML of your Content editor webpart for testing purposes.
<script type=”text/javascript”>
var currentcontext = null;
var currentweb = null;
ExecuteOrDelayUntilScriptLoaded(GetTemplates, “sp.js”);
function GetTemplates()
{
currentcontext = new SP.ClientContext.get_current();
currentweb = currentcontext.get_web();
this.listTemplateCollection = currentweb.get_listTemplates();
currentcontext.load(listTemplateCollection);
currentcontext.executeQueryAsync(Function.createDelegate(this, this.ExecuteOnSuccess),
Function.createDelegate(this, this.ExecuteOnFailure));
}
function ExecuteOnSuccess(sender, args){
var listTemplateEnumerator = this.listTemplateCollection.getEnumerator();
var listtemplateInfo =”";
while (listTemplateEnumerator.moveNext())
{
var listTemp = listTemplateEnumerator.get_current();
listtemplateInfo += listTemp.get_name() + ‘\n’ + listTemp.get_listTemplateTypeKind(); + ‘\n’;
}
alert(listtemplateInfo);
}
function ExecuteOnFailure(sender, args) {
alert(“Error in Getting List ID”);
}
</script>
Related Post : Get Site templates using javascript client object model – SharePoint 2010





