简体   繁体   中英

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. In order to determine the current user, I am calling $().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

<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. One of which is the fieldName. You should pass it a fieldName like maybe Title which will return the person Full Name. 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM