Friday, March 1, 2013

jQuery : Hiding or unhiding SharePoint DateTime control

We were required to hide/unhide based on selection change event of a drop down control. As DateTime control is not just a single control (textbox, imaget etc) I could not get to hide everything together. Image icon specially. After having lot of trouble with it, finally this is what I did. I am not sure if it is a rude way or nice way of doing it, so would like to hear from anyone or any post about it would be helpful.
jQuery was working fine with other controls and some div tags. So I put a div tag around the date time control and hiding/showing the div tag instead of the Datetime control. Here is the code
 $(function () {
        $("#divStep2DateOfChange").hide();
        $("#<%=ddllist.ClientID%>").on('change', function(e) { 
            $("#divStep2DateOfChange").show();
         });
    });

This code initially hides when the page is loaded, and the control is back when a value is changed in the drop down ddllist.

No comments:

Post a Comment