Javascript JqueryUI对话框不';无法使用特定的输入名称
我在使用JqueryUI对话时遇到了一个奇怪的困难。当输入名称为“提交”时,此代码不起作用。它适用于所有其他输入名称(例如:submit2)。有人知道为什么以及如何解决这个问题,因为我不能因为不同的原因更改输入名称吗?Jquery脚本中有错误,我找不到什么Javascript JqueryUI对话框不';无法使用特定的输入名称,javascript,jquery,jquery-ui,jquery-ui-dialog,Javascript,Jquery,Jquery Ui,Jquery Ui Dialog,我在使用JqueryUI对话时遇到了一个奇怪的困难。当输入名称为“提交”时,此代码不起作用。它适用于所有其他输入名称(例如:submit2)。有人知道为什么以及如何解决这个问题,因为我不能因为不同的原因更改输入名称吗?Jquery脚本中有错误,我找不到什么 <form action="?" method="get" class="alert2"> <input name="test" type="text" value="dataaaa" /> <i
<form action="?" method="get" class="alert2">
<input name="test" type="text" value="dataaaa" />
<input name="submit" type="submit" value="RECORD" />
</form>
$(function () {
var confirmdialog = $('<div id="dialog"></div>').appendTo('body');
$("#dialog").dialog({
modal: true,
bgiframe: true,
width: 300,
height: 200,
autoOpen: false,
title: 'Confirm'
});
$('form.alert2 input[type=submit]').click(function (theINPUT) {
theINPUT.preventDefault();
var theFORM = $(theINPUT.target).closest("form");
$('#dialog').html('<P>confirm ?</P>');
$("#dialog").dialog('option', 'buttons', {
"Confirm": function () {
theFORM.submit();
},
"Cancel": function () {
$(this).dialog("close");
}
});
$("#dialog").dialog("open");
});
});
$(函数(){
var confirmdialog=$('').appendTo('body');
$(“#对话框”)。对话框({
莫代尔:是的,
bgiframe:是的,
宽度:300,
身高:200,
自动打开:错误,
标题:“确认”
});
$('form.alert2 input[type=submit]')。单击(函数(输入){
input.preventDefault();
var theFORM=$(theINPUT.target);
$('#dialog').html('确认?
');
$(“#对话框”)。对话框('选项','按钮'{
“确认”:功能(){
submit()格式;
},
“取消”:函数(){
$(此).dialog(“关闭”);
}
});
$(“对话框”)。对话框(“打开”);
});
});
单击事件对按钮类型的元素有效。当元素类型保持为“提交”时,单击事件将无法生成预期输出
你能试试下面的吗
<form action="?" method="get" class="alert2">
<input name="test" type="text" value="dataaaa" />
<input name="submit" type="button" value="RECORD" />
</form>
$(function(){
var confirmdialog = $('<div id="dialog"></div>').appendTo('body');
$("#dialog").dialog({
modal: true,
bgiframe: true,
width: 300,
height: 200,
autoOpen: false,
title: 'Confirm'
});
$('form.alert2 input[type=button]').click(function(theINPUT){
theINPUT.preventDefault();
var theFORM = $(theINPUT.target).closest("form");
$('#dialog').html('<P>confirm ?</P>');
$("#dialog").dialog('option', 'buttons', {
"Confirm" : function() {
theFORM.submit();
},
"Cancel" : function() {
$(this).dialog("close");
}
});
$("#dialog").dialog("open");
});
});
$(函数(){
var confirmdialog=$('').appendTo('body');
$(“#对话框”)。对话框({
莫代尔:是的,
bgiframe:是的,
宽度:300,
身高:200,
自动打开:错误,
标题:“确认”
});
$('form.alert2 input[type=button]')。单击(函数(输入){
input.preventDefault();
var theFORM=$(theINPUT.target);
$('#dialog').html('确认?
');
$(“#对话框”)。对话框('选项','按钮'{
“确认”:函数(){
submit()格式;
},
“取消”:函数(){
$(此).dialog(“关闭”);
}
});
$(“对话框”)。对话框(“打开”);
});
});
对话框的哪个部分不起作用?这里看起来不错,谢谢你的回答,但它不起作用。我需要保留这段代码你安装了firebug吗-?如果有任何错误,它将在控制台>错误部分显示错误。你能检查它并用你得到的错误更新你的问题吗?正如j08691用户所评论的,您的代码正在JSFIDLE上运行。jsfiddle.net/j08691/82x9j3qs此表单未提交。我不明白为什么。Firebug中没有错误。我发现:如果有人有问题(除了更改输入名称),那就太好了