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>

2 Answers 2

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 () { };
}
0
2

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

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

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.