Monday, January 26, 2015

JSOM in SharePoint 2013 Application Page.

In this  post, I am talking about how to use the auto intellisense in the Visual Studio 2012  when you decided to use the JavaScript Object Model in an application page.

If you are familiar with SharePoint App model development using NAPA or Visual Studio, you might seen the required JS files from JSOM,

  • jquery-1.9.1.js
  • MicrosoftAjax.js
  • SP.Core.js"
  • SP.Runtime.js
  • SP.js
loads from the _layout folders but those are not useful when you wanted to use auto intellisense in the Visual Studio.
The hardcore developer knows how the intellisense are useful in the language,especially on Debugging.

There are so many namespaces,properties and methods are introduced in SP.JS,and we can identify them and leverage in our application using the auto intellisense feature of Visual Studio.


Follow these steps to achieve this,

Inside your layout folder in the Solution add the "Script" folder.
Create the _references.js file
Add the below JS files from the "Layout" folder under "Template" folder in 15 hive.

  • jquery-1.9.1.js
  • MicrosoftAjax.js
  • SP.Core.js
  • SP.Runtime.js
  • SP.js

Now in your application page under"PageHead" content area include the script tags and reference them using src property.

Now you are ready to go javascript function,and check the auto intellisense available for your objects.
But be ensure that _reference.js files looks like in the screen and added to your script folder inside your layout project folder.