Uncaught TypeError: $(...).dialog is not a function 但是我在 stack 看了一下,说要加这个 dialog function 但是我在代码中的确是加了这个。
/**
* Created by Administrator on 2017/4/13.
*/
$(function () {
var admin_flag = [
{ Name: "否", Id: 0 },
{ Name: "是", Id: 1 }
];
query_user='/api/users';
$.getJSON(query_user,function (user_data) {
clients=user_data['data'];
$("#jsGrid").jsGrid({
height: "400px",
width: "100%",
filtering: true,
editing: true,
sorting: true,
paging: true,
autoload: true,
rowClick: function(args) {
showDetailsDialog("Edit", args.item);
},
// controller: db,
pageSize: 10,
pageButtonCount: 5,
deleteConfirm: "真的要删除喵?",
data: clients,
fields: [
{ name: "name", type: "text", width: 150, validate: "required"},
{ name: "email", type: "text", width: 150,validate: "required" },
{ name: "created_time", type: "text", width: 200 },
{ name: "admin_flag", type: "select", items: admin_flag, valueField: "Id", textField: "Name" },
// { name: "Married", type: "checkbox", title: "Is Married", sorting: false },
// { name: "password",type: "text", width: 150, validate: "required"},
{
type: "control",
modeSwitchButton: false,
editButton: false,
headerTemplate: function() {
return $("<button>").attr("type", "button").text("Add")
.on("click", function () {
showDetailsDialog("Add", {});
});
}}
]
});
$("#detailsDialog").dialog({
autoOpen: false,
width: 400,
close: function() {
$("#detailsForm").validate().resetForm();
$("#detailsForm").find(".error").removeClass("error");
}
});
$("#detailsForm").validate({
rules: {
name: "required",
email: { required: true },
created_time: { required: true, minlength: 10 },
admin_flag: "required"
},
messages: {
name: "Please enter name",
email: "Please enter valid age",
created_time: "Please enter created_time (more than 10 chars)",
admin_flag: "Please enter admin_flag"
},
submitHandler: function() {
formSubmitHandler();
}
});
var formSubmitHandler = $.noop;
var showDetailsDialog = function(dialogType, client) {
$("#name").val(client.name);
$("#email").val(client.email);
$("#created_time").val(client.created_time);
$("#admin_flag").val(client.admin_flag);
// $("#married").prop("checked", client.Married);
formSubmitHandler = function() {
saveClient(client, dialogType === "Add");
};
$("#detailsDialog").dialog("option", "title", dialogType + " Client")
.dialog("open");
};
var saveClient = function(client, isNew) {
$.extend(client, {
name: $("#name").val(),
email: parseInt($("#email").val(), 100),
created_time: $("#created_time").val(),
admin_flag: parseInt($("#admin_flag").val(), 100)
// Married: $("#married").is(":checked")
});
$("#jsGrid").jsGrid(isNew ? "insertItem" : "updateItem", client);
$("#detailsDialog").dialog("close");
};
});
});
any help thx in advance.
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.