We are following jQuery best practice and using the jQuery document ready function (that is, $(document).ready(...)) to register the event handlers for our web page's slider control and initialize our web page elements:
$(document).ready(function() {
/ Event listener for Slider value changes.
$("input[type=range].brightnessLevel")
.on('input', function() { / (7)
brightness_level = $(this).val(); / (8)
payload = { "level": brightness_level } / (9)
postUpdate(payload);
});
/ Initialize slider value form state on server.
getState() / (10)
});
</script>
</head>
On line (7), we register an event handler for the slider controls input event. This handler function will be called when a user interacts with the slider on...