ユーザーからの応答を確認するために .net プロジェクトで使用する jQuery でポップアップする Yes/No 確認ウィンドウを作成する関数を作成しました。クリックした内容に応じて機能をトリガーするボタンを生成しました。
//ローカライズされた方法で物事を確認するための特別なポップアップをロードする 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));
});
}
さて、難しい部分が来ます。同社はまた、キーを押して yes/no 機能をトリガーすることも望んでいます。Enter キーは yes をトリガーし、エスケープは no をトリガーする必要があります。このタイプのセットアップでこれを行う方法がわかりません。
そこにあるほとんどのコードは無視できます。サーバーからローカライズされた文字列を取得することです。私が理解できないのは、keydown()イベントを追加することです。
何か案は?