I have a form that i use in jqgrid in add/edit popup
@using (Html.BeginForm("Action", "Controller", FormMethod.Post, new { id = "formId" }))
{
//...
}
When i click a row that form opens. If i press the textbox and click ENTER this form submits. And it submits as a regular post request, not by using jqgrid. But if i click on the Save button it works as required.
buttons: {
'Save': function () {
if ($('#formId').valid()) {
$.ajax({
type: 'POST',
url: '@Url.Action( "Action", "Controller" )',
data: $('#formId').serialize(),
success: function (json) {
$("#grid").trigger("reloadGrid");
},
error: function (e) {
alert("Unable to save." + e);
},
dataType: "application/JSON"
});
$("#divForm").dialog('close');
}
},
But i want that when i click ENTER that will be as the save button click.
Try subscribing for the submit event of the form:
and then:
and now in the
Savebutton click force the form submission:but probably it would be better to use the form’s submit button to submit a form.