I'm showing a lookup field using Radio buttons instead of Dropdown Select as this is easier to change on mobile phones.
When there are some options to show it appears fine. But when there are no options available to select, then only the help string appears in place of radio buttons. I want to place a friendly message instead. So I search for how many radio buttons are available on the page, like this:
$(document).ready(function() {
if ($('[name^="x_timeslot_id_"]').length == 0) {
console.log("No Options!");
};
});
But no radio buttons are found here. It seems the actual list of radio buttons is loaded by Ajax, so the list is not available from inside $(document).ready. I can find the list if I search when some item is clicked, so the code is fine.
How to check in Document Ready function (or elsewhere) if there are zero options, so that I can put a friendly message?
What would be the best way to place a message there to state that there are no options available?
Thank you for help!