你有一个带有输入数据的表格。像
<form id = 'myform'>
...
<td><input type="checkbox" name="supplier_aid" value="on" checked disabled >{$output.t_artikelnr}</td>
<td><input type="checkbox" name="descshort" value="on">{$output.t_kurztext}</td>
<td><input type="checkbox" name="buyer_aid" value="on">{$output.t_sap_materialnr}</td>
...
</form>
在准备好文档时,我用我的函数替换了默认的提交函数(唯一的方法,遗留代码再次出现......)
document.myform.submit = function (){
//do some stuff..
//and eventually
return true;
}
但现在没有表单提交发生......谁知道我怎样才能恢复提交行为?
这是整个js
<script type="text/javascript">
$(document).ready(function(){
document.articlelistform.progress = {};
document.articlelistform.progress.update = function(){
var variables = document.articlelistform.progress;
var state = variables.data.done / variables.data.togo;
if(document.articlelistform.progress.lock){
variables.bar.updateProgress(state,'{/literal}{$output.m_queue_progress_message_status}{literal}')
return;
}
if(typeof(variables.togo) =='undefined'){
variables.togo = 5;
}
switch(variables.data.state){
case 'inQue':
variables.bar.updateProgress((5 - variables.togo) / 5,'{/literal}{$output.m_queue_progress_message_gathering}{literal}');
variables.togo--;
if(variables.togo <= 0) variables.togo = 5;
document.articlelistform.submit(variables.data);
break;
case 'inProcess':
if(variables.togo <= 0 || variables.data.update){
variables.togo = 5;
variables.bar.updateProgress(state,'{/literal}{$output.m_queue_progress_message_genarating}{literal} '+ variables.data.done + '/' + variables.data.togo);
document.articlelistform.submit(variables.data);
}else variables.togo--;
break;
case 'downloadDone':
variables.bar.updateProgress(1,'{/literal}{$output.m_queue_progress_message_download}{literal}!');
if(window.location != 'failed'){
window.location = variables.data.location;
clearInterval(variables.ticking);
delete variables.ticking;
variables.togo = 5;
variables.state = 'new';
}else{
document.articlelistform.progress.bar.updateProgress(1,'{/literal}{$output.m_queue_progress_message_networkerr}{literal}!');
}
break;
case 'error' :
clearInterval(variables.ticking);
delete variables.ticking;
variables.togo = 5;
variables.state = 'error';
document.articlelistform.progress.bar.updateProgress(1,'{/literal}{$output.m_queue_progress_message_server_error}{literal}');
document.articlelistform.submit(variables.data);
break;
}
}
document.articlelistform.submit = function(data){
var settings = document.articlelistform.progress;
settings.lock = true;
if(typeof(data) == 'undefined') data = {state:'new'};
if(typeof(settings.data) != 'undefined')
if(settings.data.state == 'downloadDone'){
window.location = settings.data.location;
return false;
}
if(typeof(data) == 'object')
if(data.state == 'error') document.articlelistform.submit()
$('#formSettings').val(JSON.stringify(data));
$.ajax({
type: "POST",
url: 'ajax-backend/downloadCatalogueProgress.php',
data: $(this).serialize() ,
success: function(data){
settings.lock = false;
if(!data.error){
if((data.state == 'inQue' && typeof(settings.bar) == 'undefined')||data.progress){
delete data.progress;
$('#catalogMessageHolder').html('');
settings.bar = new Ext.ProgressBar({
renderTo: 'catalogMessageHolder',
value: 0.1,
width: 200,
maxValue:60,
minValue: 0,
text : '{/literal}{$output.m_queue_progress_message_genarating}{literal}.'
});
settings.data = data;
document.articlelistform.progress.ticking = setInterval(settings.update, 1000, data, true);
}else{
settings.data = data;
}
$('#cataloLoaderHolder').show();
}else{
//@todo: implement a warning message
}
},
failure: function(){
document.articlelistform.progress.bar.updateProgress(1,'{/literal}{$output.m_queue_progress_message_networkerr}{literal}!');
}
});
return true;
};
});
</script>