Reader small image

You're reading from  Practical Python Programming for IoT

Product typeBook
Published inNov 2020
Reading LevelIntermediate
PublisherPackt
ISBN-139781838982461
Edition1st Edition
Languages
Right arrow

Registering event handlers with jQuery

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...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Practical Python Programming for IoT
Published in: Nov 2020Publisher: PacktISBN-13: 9781838982461