Skip to content

Commit

Permalink
Save updated status in DOM
Browse files Browse the repository at this point in the history
  • Loading branch information
jthompson-arcus committed Dec 5, 2024
1 parent a746b2e commit 546b4e4
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion R/shiny.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ checkbox_callback <- DT::JS(
"var rowIdx = table.row($(this).closest('tr')).index();",
"var ids = cell.data().ids;",
"var review = $(this).is(':indeterminate') ? null : $(this).is(':checked');",
"cell.data().updated = review;",
"var info = {review: review, ids: ids, row: tblId + '_row_' + rowIdx};",
"Shiny.setInputValue(tblId + '_review_selection:CS.reviewInfo', info);",
"})"
Expand All @@ -20,9 +21,10 @@ checkbox_callback <- DT::JS(
checkbox_render <- DT::JS(
"function(data, type, row, meta) {",
"var reviewed = data.reviewed;",
"var updated = data.updated;",
"return `<input type='checkbox' ",
"class='${reviewed == null ? 'indeterminate' : reviewed ? 'checked' : 'unchecked'}' ",
"${reviewed ? 'checked' : ''} ",
"${updated == null ? (reviewed ? 'checked' : '') : (updated ? 'checked' : '')} ",
"${reviewed == null ? 'onclick=\"ts(this)\"' : ''}/>`;",
"}"
)
Expand Down

0 comments on commit 546b4e4

Please sign in to comment.