2

There's a web part on a list view page with button element on it. When user clicks the button all selected list items get deselected. I cannot change button element to input because it's Office UI Fabric component. I added type='button' attribute to the button so it won't reload the page, but it didn't help with selection. Any ideas?

Here's code I place to AllItems.aspx page. On button click all selected items get deselected:

<button type='button' onclick='test();return false;' >test</button>
<script>
function test() {
//nothing here
}
</script>
4

Try it. Dont forget to change web part id (MSOZoneCell_WebPartWPQ2 - id of list view web part) if it doesn't work:

var elem = document.getElementById("MSOZoneCell_WebPartWPQ2");
if (elem != null) {
    var dummyevent = new Array();
    dummyevent["target"] = elem;
    dummyevent["srcElement"] = elem;
    WpClick(dummyevent);
    SP.Ribbon.WebPartComponent.$3.deselectWebPartAndZone = function () { };
}
2

You can add a return false; to the button onclick. That should prevent the postback.

  • Already tried! Kindly check edited first message, do I miss something? – Chetvergov Apr 12 '17 at 6:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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