Posts

Showing posts from August, 2018

Common UI interactions with jQuery

In this post, I am listing some of the commonly used UI interactions when working with jQuery. Button click on pressing Enter over a text box $(document).ready(function(){ $("#btnSearch").click(function(){ $(".alert").show(); }); $("#txtName").keypress(function (e) {         var key = e.which;         if (key == 13)  // the enter key code         {             $("#btnSearch").click();             return false;         }     }); });

CRUD on SharePoint list item using JQuery Deferred promise

Add new list item. After new list item added, read all list items. This demonstrates JavaScript promise in SharePoint context. What is a Promise? A promise is an object that may produce a single value some time in the future: either a resolved value, or a reason that it’s not resolved (e.g., a network error occurred). A promise may be in one of 3 possible states: fulfilled, rejected, or pending. Promise users can attach callbacks to handle the fulfilled value or the reason for rejection. Learn more... var deferred = $.Deferred(); var siteUrl = _spPageContextInfo.webAbsoluteUrl; var listName = "SPFx"; $(function(){        bindButtonClick(); }); function bindButtonClick(){     $('#btnSubmit').on('click', function(){         addListItem().then(function(data){             getListData();         });     }); } var addListItem = function(){     var title = $('#txtTitle').val();        var fullUrl = siteUrl + "/_api/web/lists