Showing posts with label jQuery. Show all posts
Showing posts with label jQuery. Show all posts

Saturday 1 June 2013

Retrieving lookup list columns using REST SharePoint 2013 API

Problem:  I have 2 related SharePoint lists: 1) Question and a Child (linked) list 2)Comment.  I need to perform an JS call using jQuery to retrieve a specific comment item and I need to also know the Title field from it's related parent list (Question).  The 2 lists are shown below.  The post Creating related lists for SP Hosted Apps using VS2012 show you how to do this.

Resolution:
Open you browser  and check the query works:
http://dev-d8f436fea03755.apps.dev.local/SPHostedApp/_api/web/lists/getByTitle('Comment')/items(1)?$select=*,Question/Title&$expand=Question/Title
(replace the url)

jQuery Ajax code I used to call the REST API is shown below:

The ajax call is made in the document.Ready() method call.

Wednesday 6 October 2010

jQuery intellisense

Problem: jQuery is pretty useful and I'm not great at creating it.
Hypothesis: I am using jQuery version jquery-1.4.2.js to get intellisence I need to reference jquery-1.4.1-vsdoc.js, this should be removed at deployment.  You can reference the Visual Studio jQuery Intellesense file (jquery-1.4.1-vsdoc.js) either from microsoft's CDN or deploy locally to the 14 hive.

References:
http://weblogs.asp.net/scottgu/archive/2008/11/21/jquery-intellisense-in-vs-2008.aspx
http://www.devcurry.com/2010/02/visual-studio-jquery-intellisense-over.html

Samples:
Get the input from a multiline text box/Textarea
var existingComments = $("[id*='txtComments']").val();
Explaination - txt comments is an text box namely: asp:TextBox runat="server" ID="txtCommentsAmend" TextMode="MultiLine".  val() gets the inner html/content.
Append additional data to the text box
$("[id*='txtCommentsAmend']").html(existingComments + 'more info');
Explaination - using the previous example variable append additional text in the textbox.

Sunday 13 June 2010

Using embedded jQuery in xslt for SharePoint

Problem: A lot of web parts (WP) use xslt to create the html user interface(UI). You need to escape characters in order to get jQuery to work.
Initial Hypothesis:
Can use a Content Network Content copy of jQuery, has the advantage of being up-to-date and may be cached in user browser already. Issue is that may not be trusted or available on an Intranet.
jQuery file/s should be embedded in the master page (this should be activated in a feature).
Inside the xslt add the jQuery to perform your custom actions as shown below that does not escape characters: