HTML syntax error throwing error in browser
markschat opened this issue · comments
First, thanks for this amazing book 👏
The repo seems to be not up to date, else I would provide a pull request.
Chapter 13.2 (Table Buttons) contains a syntax error that leads to non-functioning code (tested with Edge, can´t confirm for other browsers).
The syntax error is contained here:
# button with onClick function
button <- sprintf(
"<a class='btn btn-primary' onClick='%s'>Click me</a>",
onclick
)
It produces this HTML output:
"<a class='btn btn-primary' onClick='Shiny.setInputValue('click', 'Volvo 142E')'>Click me</a>"
The browser is throwing this error in response: "Uncaught SyntaxError: Unexpected end of input (at (Index):1:21)"
The inner quotation marks in onClick
seem off. A possible solution to fix the error would be to use double quotation marks:
# button with onClick function
button <- sprintf(
"<a class=\"btn btn-primary\" onClick=\"%s\">Click me</a>",
onclick
)
Thanks for pointing this out, I'm really sorry that made it into the book!
I'll correct that ASAP