1
您好我有一個問題,當我的腳本完成處理時使用jquery覆蓋失敗關閉。jquery覆蓋不會關閉
我所做的只是顯示一個非常簡單的表單,將提交的值在後臺處理並添加到頁面中。一旦完成,覆蓋圖應該關閉,但是它只是停留在那裏,並且直到我進行整頁刷新時纔會去。
我的jQuery代碼看起來是這樣的:
function employmenthistory(){
$(document).ready(function(){
/**
* Modal Dialog Boxes Setup
*/
var triggers = $(".modalInput").overlay({
// some mask tweaks suitable for modal dialogs
mask: {
color: '#ebecff',
loadSpeed: 200,
opacity: 0.7
},
closeOnClick: false
});
/* User Input Prompt Modal Box */
$("#employmentprompt form").submit(function(e) {
// get user input
var name = $("#name", this).val();
var role = $('#role', this).val();
var title = $("#title", this).val();
//we need to know how many elements already exist
var elementCount = $('li.note').length;
//update server with information about this employment
$.ajax({
url: '/addempl/',
type : 'post',
data : "name=" + name + "&role=" + role + "&title=" + title + "&ec=" + elementCount,
dataType: "json",
success : function(msg){
//confirm the event was successful
if(msg.status == 'success'){
var item = msg.data;
//we now add to the ul for elements
$('ul.listing').append(item);
}else{
//failed to process so display error
$('div.message error').html('<p>We were unable to add your employment history</p><p>Please try again</p>');
}
},
error : function(err){
//failed to call server
$('div.message error').html('<p>We were unable to add your employment history</p><p>Please try again</p>');
}
});
// close the overlay
triggers.eq(0).overlay().close();
// do not submit the form
return e.preventDefault();
});
});
}
這段代碼的所有方面工作天晴,當我到達
triggers.eq(0).overlay().close();
與形式覆蓋在它仍然在頁面上。只有一個modelInput元素和窗體可以調用,所以我不知道爲什麼這是失敗的。
所有我所做的就是按照這可以在這裏找到了例子:
http://flowplayer.org/tools/demos/overlay/modal-dialog.html
任何幫助,這將受到歡迎。
謝謝。
黯然。 – 2011-05-04 20:52:16
請參閱我的更新與工作演示。 – Dutchie432 2011-05-05 12:52:52