2014-10-16 31 views
0

我建立了一个新的定制和编辑的形式在SharePoint 2007中使用jQuery 1.11,已定制的,我展示或基于一组对应的复选框隐藏行项目风格领域。 jquery的功能工作正常,但是现在来自sharepoint的日期选择器功能似乎不适用于我隐藏然后再次显示的字段。当我通过删除样式标签(display:none)取消隐藏元素时,日期选择器正常工作,但只要jquery触及它,功能就会消失。下面是我的一些代码的例子。jQuery的显示/隐藏断裂的SharePoint日期选择器功能

HTML

<tr id="trtohideshow" style="display:none"> 
<td>Line Item Label</td> 
<td>Sharepoint date field with picker<td> 
</tr> 

JS

//Show hide line item referral info based on check box status of Services Interested In 
$("#checkboxid").on("click", function() { 
    if ($("#checkboxid").is(":checked")){ 
     $("#trtohideshow").show("slow"); 
    }else{ 
     $("#trtohideshow").hide("slow"); 
    } 
+0

'#checkboxid'是什么?不带引号,它看起来像一个变量,但可能是一个错字 – charlietfl 2014-10-17 00:25:32

+0

一个的jsfiddle将是有益的 – 2014-10-17 05:31:33

+0

是的,这是我的真实脚本变量 - 我已经改变了它引用。我不知道如何将sharepoint的东西加载到jsfiddle中 – 2014-10-17 15:15:17

回答

1

最终,我通过使用展()和隐藏()越来越远,并且使用一个CSS类,而不是设置显示解决了这个问题:无作为TR上的内联样式。

我创建了以下CSS类:

<style> 
.hiderow{ 
    display:none; 
    visibility:hidden; 
} 
</style> 

和施加的.hiderow类到每个TR元件:

<table> 
<tr id="trtohideshow" class="hiderow"> 
<td>Line Item Label</td> 
<td>Sharepoint date field with picker<td> 
</tr> 
</table> 

如果是,增加了jQuery函数/删除的类的所述行取决于:检查中,我使用addClass和removeClass TR元件上:

$(("#checkboxid").on("click", function() { 
    if ($(("#checkboxid").is(":checked")){ 
     $("#trtohideshow").removeClass("hiderow"); }else{ 
     $("#trtohideshow").addClass("hiderow");} 
}); 

Ť他的代码是专为NewForm.aspx和只增加/在点击删除事件 - 如果你想实现像这样的EditForm.aspx,你需要添加下面的函数到$(文件)。就绪还有最后一个让已经检查了行得到显示在页面加载时:

if ($("#checkboxid").is(":checked")){ 
     $("#trtohideshow").removeClass("hiderow"); }else{ 
     $("#trtohideshow").addClass("hiderow");} 

这是完全一样的功能,但没有点击事件,以便选择删除类或保留权当页面加载。希望这可以帮助某人。