Last active
August 29, 2015 14:00
-
-
Save akhileshnirapure/11251482 to your computer and use it in GitHub Desktop.
Module for Web
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var userInfoWebModule = function (jQuery) { | |
// Define user class/module | |
var userModule = function () { | |
function _getUserName() { | |
var context = SP.ClientContext.get_current(); | |
var user = context.get_web().get_currentUser(); | |
context.load(user); | |
context.executeQueryAsync(onGetUserNameSuccess, onGetUserNameFail); | |
function onGetUserNameSuccess() { | |
var _msg = "Display name from Web : " + user.get_title(); | |
jQuery('#ui_web').text(_msg); | |
}; | |
// This function is executed if the above call fails | |
function onGetUserNameFail(sender, args) { | |
alert('Failed to get user name. Error:' + args.get_message()); | |
}; | |
}; | |
return { | |
getUserName : _getUserName | |
}; | |
}; | |
return userModule(); | |
}; | |
define(['jquery'], userInfoWebModule); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment