Posts

Showing posts with the label JQuery

How to handle JavaScript post back in SharePoint 2010

Scenario : Run JavaScript on page load but not on postback. Why : SharePoint does field validation on server side so it runs page load js again. Please do not forget to comment if this helps. Please use below script to avoid same : $(document).ready(function() { if((window.location.pathname).toLowerCase().indexOf("new.aspx") > 0) { if((document.referrer).toLowerCase().indexOf("new.aspx") < 0) { ExecuteOrDelayUntilScriptLoaded(functionToCall, "sp.js"); } } }); function functionToCall() { alert('Just on page load'); }

Mega menu and dashboard

Image
Example of mega menu/dashboard Example of dynamic dials Managers dashboard
Hack to make asynchronous JQuery Slider/Motion -> Synchronized. Scenario : JQuery slider contains 8+ images. 4 images are visible on screen at a time and user can click next and previous links to move slider. But if user clicks next/previous button multiple times. Slider's UI breaks. We have to stop user from clicking next/previous second time if slider is moving or in progress. var isProcessing = 0; var waitMiliSec = 1100; var objInterval;   function moveToPrevious() { if (isProcessing == 0) { setIsProcessing(1, 0); objInterval = setInterval(function () { setIsProcessing(0, 1) }, waitMiliSec); //Slider's asynchronyzed slide code //Any JQuery asynchronyzed code }     } function moveToNext() { if (isProcessing == 0) { setIsProcessing(1, 0); objInterval = setInterval(function () { setIsProcessing(0, 1) }, waitMiliSec); //Slider's asynchronyzed slide code //Any JQuery asynchronyzed code } }     fun...