[英]jquery dialog gives missing : after property id error
I am trying to popup the jquery dialogue box here. 我正在尝试在此处弹出jquery对话框。 when I dialog has the following code..
当我对话框具有以下代码时。
var opt = {
autoOpen: false,
modal: true,
width: 550,
height:650,
title: 'Details'
};
It works fine. 工作正常。 I get the popup window.
我得到弹出窗口。 But adding additional info is getting me this error.
但是添加其他信息会使我遇到此错误。
Updated Post 更新的帖子
<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>
Any idea?? 任何想法?? Thank you for your time..
感谢您的时间..
Your syntax is wrong. 您的语法错误。 You are creating a javascript object, the syntax for which is:
您正在创建一个javascript对象,其语法为:
var opt = {
box: $( "#box" ),
itemname: $( "#itemname" ),
size: $( "#size" ),
potency: $( "#potency" ),
quantity: $( "#quantity" ),
.
.
}
Also, the var
ahead of box
is not needed. 此外,
var
提前box
是没有必要的。
You can also do it as: 您也可以按照以下方式进行操作:
var opt = new Object();
opt.box = $( "#box" );
opt.itemname: $( "#itemname" );
.
.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.