Document ready UI Script

Daryll Conway
Giga Guru

I'm trying to use a document ready function in a UI Script to capture the current user...

var $j = jQuery.noConflict(true);

              $j(document).ready(function () {

                      user = gs.getUserID();

                      alert(user);

              });

This doesn't work.

Has anyone used a document ready function in a UI script or an equivalent that has worked.

Failing that can anyone tell me how I can get the current user in a UI Script?

1 ACCEPTED SOLUTION

UI script sometimes doesn't have access g_user object .. Do a glideajax and return gs.getUserID from the script include


View solution in original post

9 REPLIES 9

venkat2
Kilo Expert

Hi,



Please try the client side expressions



var userName = g_user.userName;


    alert('Current user = ' + userName);


ProbirDas
Tera Expert

Var usr = "${gs.getUserID ()}";


alert (usr);


Kalaiarasan Pus
Giga Sage

I have used document ready function in couple of UI pages.. Works just well. The only error I notice here is



gs.getUserID();   which is a server side function.. Make use of the equivalent client side object and that should work just fine ...


I've tried using g_user.userID but I get an undefined.


This is purely a UI script that act's upon the 'nav_header_stripe_decorations' element (the top banner).



Just wanted to clarify I'm not using a UI Page (otherwise I would have used jelly to solve this, which I've done before)