JQGrid 在编辑弹出窗口中单击 ENTER
我有一个在 jqgrid 中添加/编辑弹出窗口中使用的表单,
@using (Html.BeginForm("Action", "Controller", FormMethod.Post, new { id = "formId" }))
{
//...
}
当我单击表单打开的行时。如果我按文本框并单击 ENTER,则此表单会提交。它作为常规的 post 请求提交,而不是使用 jqgrid。但如果我单击“保存”按钮,它就会按要求工作。
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');
}
},
但我希望当我单击 ENTER 时,这将作为保存按钮单击。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试订阅表单的提交事件:
然后:
现在在“保存”按钮中单击强制表单提交:
但可能最好使用表单的提交按钮来提交表单。
Try subscribing for the submit event of the form:
and then:
and now in the
Save
button click force the form submission:but probably it would be better to use the form's submit button to submit a form.