Reactive JS elements in shiny

I have a shiny application with DT table. In this table, i have incorporated JS as shown below. Everything is working fine. But I need JS elements to be reactive

For example the current JS is shown below

DT::datatable(........ ,
                      callback = JS("
  table.column(1).nodes().to$().css({cursor: 'pointer'});
                                      var format = function(d) {
                                      return '<div style=\"background-color:red; padding: .5em;text-align:center;\"><table><tr><td><b> Tag </b></td><td><b> Number of Reviews </b></td><td><b> Share </b></td><td><b>Click</b></td></tr><tr><td> '+d[6]+' </td><td>' + d[16] + '</td><td>' + d[26] + '</td><td>' + d[36] + '</td></tr><tr><td> '+d[7]+' </td><td>' + d[17] + '</td><td>' + d[27] + '</td><td>' + d[37] + '</td></tr><tr><td> '+d[8]+' </td><td>' + d[18] + '</td><td>' + d[28] + '</td><td>' + d[38] + '</td></tr><tr><td> '+d[9]+' </td><td>' + d[19] + '</td><td>' + d[29] + '</td><td>' + d[39] + '</td></tr><tr><td> '+d[10]+' </td><td>' + d[20] + '</td><td>' + d[30] + '</td><td>' + d[40] + '</td></tr><tr><td> '+d[11]+' </td><td>' + d[21] + '</td><td>' + d[31] + '</td><td>' + d[41] + '</td></tr><tr><td> '+d[12]+' </td><td>' + d[22] + '</td><td>' + d[32] + '</td><td>' + d[42] + '</td></tr><tr><td> '+d[13]+' </td><td>' + d[23] + '</td><td>' + d[33] + '</td><td>' + d[43] + '</td></tr><tr><td> '+d[14]+' </td><td>' + d[24] + '</td><td>' + d[34] + '</td><td>' + d[44]  + '</td></tr><tr><td> '+d[15]+' </td><td>' + d[25] + '</td><td>' + d[35] + '</td><td>' + d[45] + '</td></tr></table ></div>';
                                      };
                                      table.on('click', 'td.details-control', function() {
                                      var td = $(this), row = table.row(td.closest('tr'));
                                      if (row.child.isShown()) {
                                      row.child.hide();
                                      td.html('&plus;');
                                      } else {
                                      row.child(format(row.data())).show();
                                      td.html('&minus;');
                                      }
                                      });"
                      )
)

But this d[16], d[36] etc..... numbers needs to be reactive. Can we pass reactive elements to this? Just gave a sample code above. Please guide me

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.