0
我想在这里弹出jquery对话框。 当我对话框 具有以下代码..jquery对话框丢失:在属性ID错误后
var opt = {
autoOpen: false,
modal: true,
width: 550,
height:650,
title: 'Details'
};
它工作正常。我得到了弹出窗口。但添加额外的信息让我这个错误。
更新后
<script>
$(document).ready(function(){
$(".editbt").click(function(event) {
event.preventDefault();
$.ajax({
type: "GET",
url: this.href,
cache:false,
success: function(response){
var opt = {
box :$("#box"),
itemname:$("#itemname"),
size:$("#size"),
potency:$("#potency"),
quantity:$("#quantity"),
allFields:$([]).add(box).add(itemname).add(size).add(potency).add(quantity),
tips :$(".validateTips");
function updateTips(t) {
tips
.text(t)
.addClass("ui-state-highlight");
setTimeout(function() {
tips.removeClass("ui-state-highlight", 1500);
}, 500);
}
function checkLength(o, n, min, max) {
if (o.val().length > max || o.val().length < min) {
o.addClass("ui-state-error");
updateTips("Please enter the field ");
return false;
} else {
return true;
}
}
function checkRegexp(o, regexp, n) {
if (!(regexp.test(o.val()))) {
o.addClass("ui-state-error");
updateTips(n);
return false;
} else {
return true;
}
}
$("#dialog-form").dialog({
autoOpen: false,
height: 600,
width: 500,
modal: true,
buttons: {
"edit": function() {
var bValid = true;
allFields.removeClass("ui-state-error");
bValid = bValid && checkLength(box, "box", 1, 16);
bValid = bValid && checkLength(itemname, "itemname", 1, 16);
bValid = bValid && checkLength(size, "size", 1, 16);
bValid = bValid && checkLength(potency, "potency", 1, 16);
bValid = bValid && checkLength(quantity, "quantity", 1, 16);
if (bValid) {
$("#users tbody").append("<tr>" +
"<td>" + box.val() + "</td>" +
"<td>" + itemname.val() + "</td>" +
"<td>" + size.val() + "</td>" +
"<td>" + potency.val() + "</td>" +
"<td>" + quantity.val() + "</td>" +
"</tr>");
$(this).dialog("close");
}
},
Cancel: function() {
$(this).dialog("close");
}
},
close: function() {
allFields.val("").removeClass("ui-state-error");
}
});
};
if (response.length > 0) {
var wrapperelement = document.getElementById('display');
wrapperelement.innerHTML = response;
$("#dialog-form").dialog(opt).dialog("open");
}
}
});
});
});
</script>
任何想法?谢谢你的时间..
:'
你也可以做到这一点的?你有没有打扰检查控制台的错误?错误是自我解释的。 – lifetimes 2013-05-13 09:58:39
@天顶是的我没有检查..它显示了错误..我不知道这是对象创建..我正在做它的第一次.. – user2234992 2013-05-13 10:10:05
我不想被粗鲁的方式,它是只要将代码粘贴到JSbin中或检入控制台,就会看到每个错误以及造成它的原因。你应该总是这样做,然后发布 – lifetimes 2013-05-13 10:11:48