I want to be able to press "ENTER", and in the dialog box perform the same function as the submit button.
I found a similar question here: Send jQuery UI to <Enter> . I added some of the solutions to the code and nothing fixed the problem.
This is what I have so far:
Button:
<button id="myButton">Execute Tasks</button>
The dialog itself:
<div id='myDialog' title="New Task(s):">
<p>Enter the name of the tasks you wish to execute</p>
<form>
<label for="name">
<input type="text" name="name" id="name" />
</label>
</form>
</div>
Inside the script tags:
$('#myButton').click( function() {
$( "#myDialog" ).dialog({
open: function(){
$("#myDialog").unbind('submit');
$("#myDialog").submit(function() {
$("#myDialog").parents('.ui-dialog').first().find('.ui-button').first().click();
return false;
});
},
buttons: {
"Run tasks": function() { .... },
"Cancel":function() { $(this).dialog("close"); };
},
});
});
source
share