IE8只提交按钮,不提交?

所以,这很奇怪,在我做了一堆代码更新之前,大约一个月前它对我有用。 无论如何问题是实时提交处理程序甚至不会在IE8中运行,但是,如果我在按钮单击运行它,它的工作原理。 见下文:

HTML

 



  • (No Files Added, Yet)

JavaScript的:

 function file_upload($theform,item_id){ $theform.attr('ACTION','io.cfm?action=updateitemfile&item_id='+item_id); if($theform.find('[type=file]').val().length > 0){ $('iframe').one('load',function(){ $livepreview.agenda({ action:'get', id:item_id, type:'item', callback:function(json){ $theform.siblings('.upload_output').append('
  • '+json[0].files.slice(-1)[0].file_name+' [X]
  • ').children('li').fadeIn(); $theform.siblings('.upload_output').find('.nofiles').remove(); } }); //Resets the file input. The only way to get it cross browser compatible as resetting the val to nothing //Doesn't work in IE8. It ignores val('') to reset it. $theform.append('').children('[type=reset]').click().remove(); }); } else{ $.alert('No file selected'); return false; } } /* FILE UPLOAD EVENTS */ //When they select "upload" in the modal $('.file_upload').live('submit',function(event){ alert('hello world'); file_upload($('.agenda-modal .file_upload'),$('.agenda-modal').attr('data-defaultitemid')); }); /* This is the code that makes it work..., but i dont want it! it should alert hello world on the submit button! */ $('.test').live('click',function(event){ $('.file_upload').submit(); });

    这是设计上的,并没有完全与IE 8隔离。在所有浏览器中一直都是这样。

    如果您调用submit方法,则只有在使用提交按钮提交表单时才会发生submit事件。

    1. 而不是创建重置按钮,模拟点击事件并销毁它 – 为什么不呢

       $('.file_upload').reset(); 
    2. 你真的需要现场提交表格吗? 如果按钮始终保留在DOM中,请使用正常的点击事件

       $('.test').click(function(){ $('.file_upload').submit(); });