I am using an XSLTWebPart in SharePoint 2013 and when the user clicks on other elements of the page (outside the web part) certain sections trigger the webpart losing all selected items. I am continuing to debug through the SharePoint JavaScript files but I thought someone else might know which code specifically is triggering the selection removed and how to stop it?

I believe the WpClick method is involved but so far have not been able to find out how. I've tried on-prem and also Office 365 I have the same problem in both.

1 Answer 1


OK, figured it out. The function is DeselectAllWPItems() in core.js. The following code (you have to make sure core.js is already loaded using either ExecuteOrDelayUntilScriptLoaded or something similar). In my case I have actions which fire when the first item is selected so I apply it then.

The key for me was using the debug versions of the JavaScript files on prem and then searching for the s4-itm-selected class that I saw was being removed as they were selected.

//remove this built-in core.js function to prevent random clicks from removing the selected items
DeselectAllWPItems = function() { return; }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.