'Adding multiple rows in rhandsontable via context menu

I'm using the rhandsontablepackage and would like to add a context menu option for adding multiple rows to the handsontable produced. I've tried to adapt this example into my R equivalent with no luck. I believe my javascript is the issue but don't have the experience to spot what's wrong.

How can I add a custom context menu item for adding multiple rows? Thanks in advance.

Reprex

library(rhandsontable)

iris %>%
  head(5) %>%
  rhandsontable() %>%
  hot_context_menu(customOpts =
                     list(
                       name = "Add 5 rows at the top",
                       callback = htmlwidgets::JS(
                         "function (key, options) {
                              this.alter('insert_row', 1, 5);
                              this.render();
                              }"
                       )
                     ))


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source