jquery - Getting modal dialog to respond to Enter -
i have modal dialog box, below, reads input field when save button clicked. works fine. i'd trigger save button function when enter entered in input field. there simple way that?
thanks
dialog1$ = $('<div></div>').appendto('body') .html("<div><h6>save . . .</h6><input id='user-input' type='text'></div>"); $('#user-input').val(g.last_save_name); dialog1$.dialog({ modal: true, title: 'save websheet', zindex: 10000, autoopen: true, width: 'auto', resizable: false, buttons: { save: function () { savepage($("#user-input").val()); $(this).dialog("close"); } }, });
you bind keypress event div/element contains dialog. should work.
$(dialog1$).keypress(function(e) { if (e.keycode == $.ui.keycode.enter) { savepage($("#user-input").val()); } });
Comments
Post a Comment