I like to have control on click event to hide or show layers.
var docOCGs = this.getOCGs();
for (var x=0; x < docOCGs.length; x++)
if(docOCGs[x].name == "layer1")
docOCGs[x].state = !docOCGs[x].state;
Do not confuse "PDF events" (clicking a button, showing/hiding layers) with "InDesign events" (which are things that happen inside InDesign only, when working on an InDesign document).