Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

How to Append text to the First Value of an Array in a loop SharePoint, Javascript,REST

$
0
0

Hi,

i have a SharePoint list that i would like to have the word 'New' appended to the most recent Announcement items(Say the 1st and the 2nd items will have new appended while the rest will display as they are). But i'm not sure how to achieve this.

Any help?

var glblognews = function getBlogItems () {



        // execute AJAX request
        $.ajax({
            url: _spPageContextInfo.webAbsoluteUrl + "/Blog/_api/web/lists/getbytitle('Posts')/items?$select=Title,ID,PostCategory/Title,PostCategory/ID&$expand=PostCategory&$filter=PostCategory/Title eq 'General'",
            type: "GET",
            headers: { "ACCEPT": "application/json;odata=verbose" },
            success: function(data) {
		console.log(_spPageContextInfo);
		var items = "";
		var posturlLink= "";
		var posturl = _spPageContextInfo.webAbsoluteUrl + "/Blog/Lists/Posts/Post.aspx?ID=";
		var categoryurl = _spPageContextInfo.webAbsoluteUrl + "/Blog/Lists/Categories/Category.aspx?CategoryId=";
		//console.log(categoryurl);
        $.each(data.d.results, function(key, value) {

		posturlLink = '<li>' + '<a href="' + posturl + value.ID + '" >' + value.Title + '</a><p><span></li>';


	        $("#announcementsItems").append(posturlLink);
	   });

$(document).ready(glblognews());
	

thanks


Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>