Is it possible to send the "Enter" option to the jquery diglog plugin?

Url here:

http://jqueryui.com/demos/dialog/#modal

Suppose this dialog box contains two buttons: OK and NO,

when the "Enter" button is pressed, I want the function to be bound to the "OK" button.

How to do it?

The dialog looks something like this:

<table cellpadding="0" border="0" width="100%">
    <tr align="center">
        <td align="right">name/email:</td>
        <td><input type="text" id="name" /></td>
    </tr>
    <tr align="center">
        <td align="right" valign="top">password:</td>
        <td>
                <input type="text" id="psw" />
        </td>
    </tr>
    <tr align="center">
        <td></td>
        <td><span id="loginErr"></span></td>
    </tr>
</table>
+3
source share
4 answers

Assign the “Ok” button to the tag and give it focus (if the first does not work properly alone)

+2
source

you can easily add your custom buttons by adding your optional object

buttons: {
'Button OK': function() {
  // Do something
 },
'Button No': function() {
  // Do something
}

- :

$("#name").keydown(function(event){
    if(event.keyCode == "13") {
        // call the function for submit the form
    }
});

KeyCodes : http://unixpapa.com/js/key.html

+1

, snuffer-ch, jQuery-Hotkeys http://code.google.com/p/js-hotkeys/, :

$(document).bind('keydown', 'return', function(){
  //your code goes here
});
+1

, , , ( ).

- , keyup , <input>. , buttons ( ).

0

Source: https://habr.com/ru/post/1717224/


All Articles