0

How do I detect the selection/deselection of a list item in SP Online?

I tried the below code from this answer

$(".ms-listviewtable > tbody > tr").click(function(){
            alert("clicked");
        });

It is detecting the click on the list row but not on the checkbox in the left most cell, It is also not detecting the click on Select All/Deselect All button.

I need to detect these list item selections so that i can disable or enable the item ribbons at the top based on the selected items

0

The Checkbox has code that prevents the click event from bubbling up the DOM
That is why your TR does not receive the Click event

So don't attach the click on the whole TR, just on that CheckBox

Better yet, use the Cisar Chrome Extension to write a CSR (Client Side Rendering) field and create the code for that Completed field yourself

Note: That checkbox is created by Microsofts CSR code on the View, the moment you add a JSLink (like Cisar) does to a CSR file on the WebPart it will not execute JSLinks on the View anymore.

Start by using Cisar it will make your development life a whole lot easier

  • thanks for the suggestion. can you please add some more links on CSR tutorials.? I never worked with them yet – Abdul Hameed Mar 30 '17 at 13:16
  • The links are the starting points, then search for any blog bij Andrei Markeev. Once you have read and understood those, only then look at the CSR examples on the MSDN site – Danny '365CSI' Engelman Mar 30 '17 at 15:30

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.