[英]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"
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.