入力データを含むフォームがあります。お気に入り
<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>