Why does g_user not work on UI Page client scripts?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-12-2013 08:22 AM
I have been working on something to do with a UI Page and I am curious as to why the g_user commands (for example "g_user.userID") are not working in the UI Page Client Script box.
Is there any particular reason for this? I think that knowing the answer to why it works on some client scripts and not others will greatly enhance my knowledge of the platform.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-18-2013 02:09 AM
Geoff,
Try putting the g2 tag here instead. For some reason it doesn't work unless its right above the last jelly tag:
<div id="theResult"></div>
<g2:client_script type="user" />
</j:jelly>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-18-2013 11:01 AM
I tried it everywhere, but It doesn't seem to work anyplace!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-20-2013 01:43 PM
The reason g_user wasn't working on my page was that the page hadn't finished rendering at the time the line of script was trying to execute. The solution is to use the jQuery ready function:
The HTML:
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<!-- emit g_user support -->
<script>
jQuery(document).ready(function ($) {
doSomething();
});
</script>
<g2:client_script type="user" />
</j:jelly>
The Script:
function doSomething() {
alert(g_user.toString());
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-23-2013 12:26 PM
On the Client Script box in a UI Page, you can do things like:
alert("${gs.getUserID()}");
Little late but hope this helps you,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-11-2015 02:05 AM
addLoadEvent(displayUserSysId);
function displayUserSysId() {
getActiveUser(); // this will force load the current user
alert(g_user.userName);
}