For those looking for an answer, it seems the easiest option is to put the resource ID in a data attribute in your DOM.
You could also put it in an onclick event handler, or a hidden form field.