An eample of adding a new list in your SharePoint 2010 site using Ecmascript\Javascript Client Object Model.
<script type="text/ecmascript">
function AddNewList()
{
var context = new SP.ClientContext.get_current();
var web = context.get_web();
var listCollection = web.get_lists();
var list = new SP.ListCreationInformation();
list.set_templateType(SP.ListTemplateType.genericList);
list.set_title('myNewList');
this.listCollection.add(list);
context.load(this.listCollection);
context.executeQueryAsync(Function.createDelegate(this, this.success), Function.createDelegate(this, this.failed));
}
function success() {
alert('List Added');
}
function failed(sender, args) {
alert('failed. Message:' + args.get_message());
}
</script>
<a onclick="Javascript:AddNewList();" href="#">Create List</a>
No comments:
Post a Comment