-
Notifications
You must be signed in to change notification settings - Fork 6
ShareCoffee.REST.jQuery
Thorsten Hans edited this page Jan 16, 2014
·
5 revisions
jQuery is everywhere, therefor is ShareCoffee offering methods to easily create configuration objects which can easily be passed to jQuery's $.ajax()
method.
ShareCoffee is offering both, interaction with the AppWeb and interactions with the HostWeb. If you pass a HostWebUrl to any for.jQuery()
call, ShareCoffee will create a configuration-object which allows HostWeb-Access.
Each of the following methods is configured by a single parameter of type ShareCoffee.REST.jQueryProperties
. You can either create a new instance by using the constructor
ShareCoffee.REST.jQueryProperties()
or you can pass a JSON object with corresponding properties.
/// Create property-object by using the constructor
var properties = new ShareCoffee.REST.RequestProperties(url, payload, hostWebUrl, eTag);
/// Create a property-object by using JSON syntax
var properties2 = { url: 'web/title' };
description: TODO
$.ajax(ShareCoffee.REST.build.read.for.jQuery({ url: "web/lists/?$select=Title,Id" }))
.done(onListsLoaded)
.fail(onError);
description: TODO
var payload = {
'__metadata': { 'type': 'SP.List' },
'AllowContentTypes': true,
'BaseTemplate': 100,
'ContentTypesEnabled': true,
'Description': 'My list created by REST',
'Title': "Thorstens List"
};
$.ajax(ShareCoffee.REST.build.create.for.jQuery({url: "web/lists/", payload: payload}))
.done(onListCreated)
.fail(onError);
description: TODO
var payload = {
'__metadata': { 'type': 'SP.List' },
'Title': 'CHANGED BY REST - Thorstens list'
};
$.ajax(ShareCoffee.REST.build.update.for.jQuery({url: "web/lists('" + customListId + "')", payload: payload}))
.done(onListUpdated)
.fail(onError);
description: TODO
$.ajax(ShareCoffee.REST.build.delete.for.jQuery({url: "web/lists('" + customListId + "')"}))
.done(onListDeleted)
.fail(onError);