I have a XsltListViewWebPart
with a custom link column used for change a value on current listitem using JavaScript.
<a href="javascript:ApproveRejectRDA('{@ID}', true);" title="approve">
below javascript function...
function ApproveRejectRDA(id, approved) {
var clientContext = SP.ClientContext.get_current();
var oList = clientContext.get_web().get_lists().getByTitle('RDA');
this.oListItem = oList.getItemById(id);
if (approved == true)
oListItem.set_item('NumStato', 16);
else
oListItem.set_item('NumStato', 17);
oListItem.update();
clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
}
When I click on link, everything works properly only when the row is selected. If not, I get the following error:
Uncaught TypeError: Cannot read property 'get_current' of undefined
It seems that clientContext
has no value.
Any ideas?
Thanks