I have created functions to create a Yes/No confirm window that popups with jQuery that I use in a .net project to confirm responses from the user. I have generated buttons that trigger functions depending on what you click on.
//load a specailized popup for confirming things in a localized manner function popupConfirm(TitleKey, InstructionsKey, YesFunction, NoFunction) {
//create the service to give us the content
var agpc = new AjaxServices.AjaxPopUps();
//get the results and open the popup with the functions aligned
agpc.GetLocalizedStrings(new Array(TitleKey, InstructionsKey, "Yes", "No"), function (results) {
var content = jQuery.parseJSON(results.toString());
//get the buttons for confirm/or not
var YesNoButtons = jQuery('<div></div>', { id: 'YesNoButtons' });
var yesButton = jQuery('<a>' + content.Yes + '</a>');
var noButton = jQuery('<a>' + content.No + '</a>');
//add the event handlers
yesButton.click(YesFunction);
noButton.click(NoFunction);
//set a nice pointer for mouse over
yesButton.css({ cursor: 'pointer' });
noButton.css({ cursor: 'pointer' });
YesNoButtons.append(yesButton).append(noButton);
//show the box
openPopup("Non-JSON", YesNoButtons, eval('content.' + TitleKey), eval('content.' + InstructionsKey));
});
}
Well now comes the difficult part. The company also wants keypresses to trigger the yes/no functions. An enter key should trigger yes and escape should trigger no. I have no real idea how I will do this with this type of setup.
You can ignore most of the code in there. It is to get localized strings from the server. It the adding the keydown() event that I can't figure out.
Any ideas?