This function creates a 'Next' button for navigating to the specified next page in a Surveydown survey. The button can be activated by clicking or by pressing the Enter key.
Details
The function generates a Shiny action button that, when clicked or when the Enter key is pressed, sets the input value to the specified next page ID, facilitating page navigation within the Shiny application. The button is styled to appear centered on the page. The Enter key functionality is only active when the button is visible.
Examples
sd_next("page2", "Continue to Next Section")
#> <div style="margin-top: 0.5rem; margin-bottom: 0.5rem;">
#> <button id="next-page2" type="button" class="btn btn-default action-button" style="display: block; margin: auto;" onclick="Shiny.setInputValue('next_page', 'page2');">Continue to Next Section</button>
#> </div>
#> <script>
#> $(document).ready(function() {
#> var buttonId = 'next-page2';
#> $(document).on('keydown', function(event) {
#> if (event.key === 'Enter' && !event.repeat) {
#> var $button = $('#' + buttonId);
#> if ($button.is(':visible')) {
#> $button.click();
#> event.preventDefault();
#> }
#> }
#> });
#> });
#> </script>