javaScript and jQuery

Get selected image size by javascript

11/01/2018 12:32
 var test = {  getSelectedPictureSize: function (fileObj) {         var _deferred = $.Deferred();           var imageSize = { width: 0, height: 0 };                 var reader = new...

Find element in sharepoint dialog

10/01/2018 13:33
The case is we have scripts included in master page and there is method location. By calling this method we want to find element in open dialog and update it. As jQuery can find it in context of local dialog and not from root window, we used following code:   var modalDialog =...

Select collection subset by jQuery

29/11/2017 12:28
Use $.grep function var selectedItems = jQuery.grep(items, function (item, index) { return item.someProperty === someValue });

Use return value from Ajax call

29/11/2017 12:19
var myFunctions =  {   checkEditRightsForFolder: function (destUrl, destWebUrl, destWebId) {         var postData = JSON.stringify({ destUrl: destUrl, destWebUrl: destWebUrl, destWebId: destWebId });         var url =...

Get query string parameters by javascript

17/12/2015 05:29
function getUrlVars (url) {      var vars = [], hash;      var hashes = url.slice(url.indexOf('?') + 1).split('&');      for(var i = 0; i < hashes.length;...

Javascript function namespaces

16/12/2015 03:51
There is good practice to use namespaces in javascripts to prevent calling incorrect function in case of the same function names in various javascript blocks or files. When using namespaces, we call function from that namespace, so we are sure to call the correct one. We can define functions in...

Select multiple checkboxes by javascript

28/10/2015 10:47
<!DOCTYPE html> <html> <body> <h2>Checkbox list</h2> <input type="hidden" value="1"> <h3>Multi Operation for list items</h3> <input type="button" value ="Select all" onclick="checkAll()"/> <input type="button" value="Deselect all"...

jQuery basics

19/01/2013 03:01
Include jQuery online (or use your web application path) in <header> tag <script type="text/javascript" src=" https://jqueryjs.googlecode.com/files/jquery-1.2.6.min.js"></script> <script src="https://code.jquery.com/jquery-latest.min.js"...