I'm in the same situation with a legacy app. Window.top
will get you to the top level document if you are nested more than one deep, then you should be able to navigate down to the proper frame. To get your data attribute value use onclick="window.top.frames[0].$("#help-button").trigger('click', [this])"
to pass the current button/image as an additional argument. Then you can grab the data from the top level binding like this:
$("#help-button").on("click", function(e, additionalArgs) {
var data = 'some default value';
if(additionalArgs) {
data = $(additionalArgs).data('pagehash');
}
$("#dialog").text(data).dialog();
});
The additionalArgs value will be ignored for normal click events.