本文介绍了jQuery blockUI无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用blockUI但是虽然它没有错误但是没有错误,但它不起作用
I'm trying to use blockUI but although it passes over with no errors, it doesn't work
下面的代码都在$(文档)中.ready()函数
the code below is all within the $(document).ready() function
$("#btnSaveJob").click(function () {
if ($("#frmJobDetails").valid()) {
$("#frmJobDetails").submit();
}
});
$("#frmJobDetails").submit(function (e) {
$('#jobDetails').block({
message: 'Saving, please wait...',
centerX: true,
centerY: true,
css: {
width: '600px',
height: '300px',
border: '3px solid #FF9900',
backgroundColor: '#000',
color: '#fff',
padding: '25px'
}
});
submitNew('job');
e.preventDefault();
$('#jobDetails').unblock();
});
编辑以在submitNew函数中添加
edit to add in the submitNew function
function submitNew(submitType) {
// various variables set here
if (submitType == 'job') {
PageMethods.SubmitJobForm(propID, dateReceived,
targetResponse, targetComplete, chargeable, jobTypeID,
jobTypeText, contractID, contractText, csJobTypeID,
csJobTypeText, priorityID, priorityText, status, notes,
fnsuccesscallbackJob, fnerrorcallback);
}
else if (submitType == 'instruction') {
PageMethods.SubmitInstruction(fnsuccesscallbackInstruction,
fnerrorcallback);
}
else {
}
}
必须添加此位作为编辑抱怨我添加了太多代码....
have to add this bit in as editor complaining I've added too much code....
推荐答案
试试这个:
<script
src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script type="text/javascript"
src="https://cdnjs.cloudflare.com/ajax/libs/jquery.blockUI/2.66.0-2013.10.09/jquery.blockUI.js">
</script>
<script>
$(document).ready(function() {
$('#btnSubmit').on('click', function() {
$('#form').validate({
errorPlacement : function(error, element) {
error.insertBefore(element); // <- the default
},
rules : {
username : {
required : true
},
password : {
required : true,
},
},
messages : {
username : {
required : " Username required."
},
password : {
required : " Password required."
},
},
});
if($('#form').valid()){
$.blockUI({ message: 'Just a moment...</h1>' });
}
});
});
</script>
这篇关于jQuery blockUI无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!