简体   繁体   English

使用$()。SPServices.SPGetCurrentUser()的Sharepoint编辑表单在我移动鼠标或按下键之前不会显示

[英]Sharepoint edit form using $().SPServices.SPGetCurrentUser() not displaying until I move the mouse or hit a key

I have a custom EditForm.aspx in which I am using Javascript to hide some rows for some users. 我有一个自定义EditForm.aspx,其中使用Javascript为某些用户隐藏了一些行。 In order to determine the current user, I am calling $().SPServices.SPGetCurrentUser(). 为了确定当前用户,我在调用$()。SPServices.SPGetCurrentUser()。 My code works perfectly on one server, but on a different one, it does this weird thing -- the edit page does not display until you do something like moving the mouse or hitting a key. 我的代码可以在一台服务器上完美运行,但在另一台服务器上却可以做到这一点—直到您执行诸如移动鼠标或敲击键盘之类的操作时,编辑页面才会显示。 You just see a blank screen except for a blinking cursor where one of the text fields would be. 您只会看到一个空白的屏幕,只是其中一个文本字段所在的光标闪烁。 As soon as you move the mouse or hit a key, the page displays instantly. 只要您移动鼠标或敲击一个键,页面就会立即显示。

To narrow the range of possibilities, I removed all javascript code except this single line 为了缩小可能性的范围,我删除了除这一行外的所有JavaScript代码

<script type="text/javascript" language="javascript" src="/blah/blah/js/jquery.SPServices-0.5.8.min.js"></script>
<script type="text/javascript">
$().SPServices.SPGetCurrentUser()
</script>

from the page. 从页面。 Comment it out, the page works normally. 注释掉,页面正常工作。 Leave it in, and you get the weird behavior described above. 保留它,您会得到上述怪异的行为。 I tested the result of the function and it provides the current user correctly. 我测试了该函数的结果,它正确地提供了当前用户。 And again, on the other server, it works fine. 再次,在另一台服务器上,它工作正常。

Ideas? 有想法吗?

If you look at the SPServices.js file, you will notice that the function extends a few options. 如果查看SPServices.js文件,您会注意到该函数扩展了一些选项。 One of which is the fieldName. 其中之一是fieldName。 You should pass it a fieldName like maybe Title which will return the person Full Name. 您应该向其传递一个fieldName之类的标题,例如Title,它将返回该人的全名。 The problem is though, that is data does not exists, it seems to break. 但问题是,数据不存在,似乎已损坏。 I dont think there is really a "returns false when empty" feature to it. 我不认为它确实具有“空时返回错误”功能。

var userName = $().SPServices.SPGetCurrentUser({
fieldName: "Title"
});

SPGetCurrentUser Wiki SPGetCurrentUser Wiki

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用SPservices将文件上传到Sharepoint列表 - Upload File to Sharepoint List using SPservices 如何使用SPServices使用dropzone.js将文件上传到SharePoint文件库? - How can I use dropzone.js to upload files to a SharePoint file Library using SPServices? 使用SPServices从SharePoint中读取 - Read from SharePoint with SPServices 使用SPServices从Sharepoint列表中获取项目时,项目未定义 - Item is undefined when using SPServices to fetch items from Sharepoint list 在CAML查询中插入WHERE子句-使用SharePoint,SPServices,JavaScript和jQuery - Insert a WHERE clause in a CAML query - using SharePoint, SPServices, JavaScript, and jQuery 使用SPServices从另一个域上的Sharepoint获取总计列表项 - Get total list items from Sharepoint on another domain using SPServices 使用javascript设置字段(SharePoint 2013编辑项目表单) - Using javascript to set a field (SharePoint 2013 edit item form) 使用SPServices和jQuery时将浏览器证书发送到https SharePoint Web服务 - Sending the Browser Certificate to an https SharePoint Web Service when using SPServices and jQuery 在不使用鼠标的情况下检查和取消选中控件,因为当我们按Enter键时,按钮控件被触发 - check and uncheck the control without using the mouse,as when we hit enter key the button control gets triggered 当您按下Enter键时,我希望我的表格继续进行 - I want my form to progress when you hit the enter key
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM