sharepoint 2013 javascript object model

12
SharePoint 2013 JavaScript Object Model A look into Client Side Development Revised 04/29/2014

Upload: innotech

Post on 13-May-2015

308 views

Category:

Business


5 download

DESCRIPTION

Presented at SharePoint TechFest Dallas 2014. All rights reserved.

TRANSCRIPT

Page 1: SharePoint 2013 Javascript Object Model

SharePoint 2013 JavaScript Object Model…A look into Client Side Development

Revised 04/29/2014

Page 2: SharePoint 2013 Javascript Object Model

Topics

How to create a Declarative Deployment Solution

Benefits and Limitations of JSOM

Why context is so important?

My favorite JSOM Development Pattern

Leveraging JSOM to deliver business solutions through SharePoint

Page 3: SharePoint 2013 Javascript Object Model

APP vs SolutionProvider-hosted apps: App written in provider’s choice of language is hosted on a dedicated server or third-party hosting service.

SharePoint-hosted apps: App written in HTML and JavaScript is hosted by SharePoint.

http://msdn.microsoft.com/en-us/library/office/fp179930(v=office.15).aspx

Page 4: SharePoint 2013 Javascript Object Model

APP vs. Solution continuedDeclarative Solutions:  Visual Studio provides a mechanism for creating a Declarative Solution that is invoked by utilizing the Sandbox Solution project type and selecting to not include an assembly within the package. Note this configuration supports deployment of JavaScript files, style sheets, and xml markup files like those used to create custom actions and site columns but does not support C# code. Publishing creates a .wsp file that can be used to load into the site collection solution store.

Page 5: SharePoint 2013 Javascript Object Model

Benefits Limitations

Deploys to both O365 and On-Premises

Can’t break SharePoint farm

Easy to implement/prototype UX designs

Faster time to market

Its asynchronous and therefore slower

Objects have to be requested

Entire object model is not implemented

No feature receivers

Pay attention to what is in your CONTEXT!

Page 6: SharePoint 2013 Javascript Object Model

Why context is so important?

With server-side C# farm solutions you create an instance of an object and you have all of its properties and members available.

With client-side JSOM (actually any language) you request an object and you get nothing unless you load it into your context.

With SharePoint’s implementation of the client side libraries instantiating an object is not enough, certain properties and members must be requested explicitly.

Page 7: SharePoint 2013 Javascript Object Model

Singleton Single Object Namespacing with Object Literal Notation Pattern

Only one instance of the object on the page

Uses a single global variable to reference an object

The object contains a collection of key:value pairs with a colon separating each pair of keys and values

Syntax requires a comma to be used after each key:value pair with the exception of the last item in your object

Page 8: SharePoint 2013 Javascript Object Model

"use strict";var myclassname= { properties: { global1: null, global2: null },

init: function () { // Wires up local properties }, load: function () { // request items and load in to globa1 and global2 }}

Page 9: SharePoint 2013 Javascript Object Model

<script>

SP.SOD.executeFunc('sp.js', 'SP.ClientContext', myclassname.init);

</script>

Page 10: SharePoint 2013 Javascript Object Model

DEMO Code Sample: Live Tiles

Page 11: SharePoint 2013 Javascript Object Model

DEMO Code Sample: Asset Gallery

Page 12: SharePoint 2013 Javascript Object Model

© 2012-2014 Slalom Corporation. All rights reserved. The information herein is for informational purposes only and represents the current view of Slalom Corporation as of the date of this presentation.SLALOM MAKES NO WARRANTIES, EXPRESS, IMPLIED, OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Scott TarnellSolution PrincipalSLALOMCONSULTING

Glassdoor Best Places to Work 2014Dallas Business Journal Best Places to Work 2013Microsoft Global Office 365 Solution Partner of the Year 2012

5080 Spectrum Drive, Suite 650EAddison, TX 75001972.419.2800 main | 972.379.7534 [email protected]