首先,我不确定哪个是正确的小部件,弹出窗口或对话框。我现在要弹出窗口。我有一个表单,提交后我想在弹出窗口中显示结果。验证和 JSON 的东西在这里:
$(function(){
$.fn.serializeObject = function() {
//serializeObject function stuff
};
$(document).on('click', function() {
$('#myForm').validate({
errorPlacement: function (error, element) {
if (element.is('select')) {
error.insertAfter(element.parents('div.ui-select'));
} else {
error.insertAfter(element.parents('div.ui-input-text')); // default placement
}
},
errorElement: 'em',
submitHandler: function(form){
var wrapper = {};
var location = {};
wrapper.location = $("#newLocation").serializeObject();
$.ajax({
type: $(form).attr('method'),
url: 'server' + 'service' + '/' + 'servicecall',
dataType: 'json',
async: false,
data: JSON.stringify(wrapper),
clearform: true,
//****Here is where the fun starts**
success: function(msg) {
var ID = msg.location.id;
//other element ID's...
//pop up vars
var $popUp = $("<div/>").popup({
dismissable: true,
theme: "d",
overlayTheme: "a",
transition: "pop"
}).on("popupafterclose", function () {
$(this).remove;
});
if(msg.success){
$('#newLocation').slideUp('fast');
$popUp.popup('open').append(ID);
}
},
error: function(msg) {
$popUp.popup('open').append('Error');
}
});
return false;
},
rules: {
//rules
},
messages: {
//messages
}
});
});
我需要动态创建弹出窗口并附加一些返回的数据。我可以将返回的数据附加到成功时显示的隐藏 div/table 中,但想尝试使用动态创建的弹出窗口(或最好的对话框)来尝试此操作。我只是无法让它创建弹出窗口。有任何想法吗?