Skip to main content

Posts

Showing posts with the label JQuery

Javascript/JQuery Handle Double Click

Recently I have been working on JavaScript/Query & SharePoint client side extensively. I will be posting my learnings during the past one year in the coming few posts.  Recently I was presented with a problem that the custom solution I had provided, did not behave properly when double clicked.  Scrapping through the web, I fumbled on couple of solutions. I personally like the first approach as it is very simple.  First Approach: Click Me $("#clickMe").click(function (e) {     var $this = $(this);     if ($this.hasClass('clicked')){         alert("Double click");         //here is your code for double click         return;     }else{          $this.addClass('clicked');         //your code for single click          setTimeout(function() {                ...

Validation before Save in New or Edit form

If you want to do validation based on other column in your out of the box New or Edit form, you can do it using JQuery in SharePoint 2010. In the code below I am trying to validate a text column if the value in the status drop down list is ‘In Process’. The function PreSaveAction() gets fired when the user clicks on ‘Save’ button in the New or Edit form. In this function you can create object of the drop down list and text control and check if the text control is empty when the status is ‘In Process’. function PreSaveAction() { var selectedVal = $("select[title='Status']").find('option:selected').text(); if(selectedVal == 'In Process') { var chrgtoNum = $("input[title='SID Number']").val(); if(chrgtoNum == '') { alert('Please enter SID Number.'); return false; } else{return true;} } else {return true;} } You can see my other blog to learn h...

Validation or control form from JQuery - Default New and Edit forms

When you create a custom list, you get default edit and new forms with it. So when you are entering data or modifying it SharePoint provides you a form in a popup that enables you to enter or modify data. But then, if you want to add custom features to the new or edit form, you can do so using JQuery. In the below example, based on the valued selected in the dropdown list, I want to enable or disable other control. And I want to add this JQuery code to the New and Edit forms of the custom list. function HideColumn(stat, active) { var activeObj = $("input[title='" + active + "']"); //initially when the user opens the form, we need to check if the user has selected the status that we have written code for… //if selected value is other than Suspend, disable the control var initialVal = $("select[title='"+ stat +"']").find('option:selected').text(); if(initialVal == '...

Sharepoint search customization - Search-as-you-type (SayT), Find-As-You-Type(FAYT)

I was going through some case studies of search customizations in Sharepoint 2007. I stumbled upon something new!! JQuery for search in sharepoint. That is for implementing 'Search-as-you-type' (SayT) or Find-as-you-Type (FAYT) in sharepoint 2007. It looked so simple and prompted me to give it a try right away. This example uses JQuery and sharepoint web service to get the results for what you are typing. All at client side. No server side code needed. And some of the properties are configurable. Which makes it easier even after you deploy this on production. ;) I implemented it right away, below are some of the screenshots. As soon as you type 3 characters (can be configured), the JQuery will bring out all matching results. You can also use the arrow button (or mouse pointer) and choose the right result and hit enter. Steps to implement Now coming back to the steps for implementing it. It is fairly simple, and can be done in a matter of few minutes. 1. C...