Since SPContext.Current gets the context of the current HTTP request and SPContext.Current.ListItem
returns the current List Item I assume you to need a similar functionality in JSOM.
In SharePoint the structure _spPageContextInfo
is available on every page on the client-side that could be considered to some extent as analogue to SPContext.Current. In particular, the following properties are exposed to identify the current List Item:
pageListId
- gets the current List Unique Id
pageItemId
- gets the current List Item Id
How to retrieve current List Item using JSOM
The following function demonstrates how to retrieve current List Item:
function getCurrentListItem(success, error)
{
var context = SP.ClientContext.get_current();
var web = context.get_web();
var currentList = web.get_lists().getById(_spPageContextInfo.pageListId);
var currentListItem = currentList.getItemById(_spPageContextInfo.pageItemId);
context.load(currentListItem);
context.executeQueryAsync(
function(){
success(currentListItem);
},
error
);
}
Usage
getCurrentListItem(
function(listItem) {
var priority = listItem.get_item('Priority');
console.log(priority);
},
function(sender,args){
console.log(args.get_message());
}
);