This topic is locked
[SOLVED]

 Disable Custom Button

1/27/2021 6:16:23 PM
PHPRunner General questions
R
RBrogen author

Hi Everyone,
I have a custom button that performs a task on the selected record in the list view. I want to disable the button the same way the default for the "Delete" button is where it is greyed out until a record is checked in the list. I know there is ajax.setDisabled() but I'm not sure how to have it do this based on whether a record is checked off just like in the example images I have shown below with the Delete button.



N
Nir Frumer 1/27/2021

hi

this is how I do it on the javascript onload
//---

var id = "MyButtonID";

var button = $("[id^=" + id + "]");

Runner.addDisabledClass(button);
$(':checkbox').change(function() {
var c = $('input[name="selection[]"]:checked').length;
if (c>0) {

Runner.delDisabledClass(button);
} else {
Runner.addDisabledClass(button);
}

});

//---
hope it helps,

Nir.

R
RBrogen author 1/27/2021

Hey Nir ... THANK YOU that worked perfectly! I had gotten the disable to work but couldn't get the checkbox function part to work so your solution was exactly what I needed! Thanks again and have a great evening!



hi

this is how I do it on the javascript onload
//---

var id = "MyButtonID";

var button = $("[id^=" + id + "]");

Runner.addDisabledClass(button);
$(':checkbox').change(function() {
var c = $('input[name="selection[]"]:checked').length;
if (c>0) {

Runner.delDisabledClass(button);
} else {
Runner.addDisabledClass(button);
}

});

//---
hope it helps,

Nir.