如何触发提交使用jQuery表格时使用的类型没有呈现按钮=提交? [英] How to trigger submit using jQuery Form when button is not rendered using type=submit?
本文介绍了如何触发提交使用jQuery表格时使用的类型没有呈现按钮=提交?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
鉴于这种形式
<form id="posts_form">
<input type="file" value="" name="picture" >
<span class="picture_js fc-button fc-button-prev fc-state-default fc-corner-left fc-corner-right">
<span class="fc-button-inner">
<span class="fc-button-content save_button">Share</span>
<span class="fc-button-effect">
<span></span>
</span>
</span>
</span>
</form>
我用这个&LT;跨度&GT;
基础按钮样式的目的
I'm using this <span>
based button for style purposes.
我试图做的是在绑定一个click事件的&LT;跨度&GT;
按钮,触发一个提交功能,如:
What I'm trying to do is bind a click event on the <span>
button and fire a submit function, like:
$('.picture_js').click(function(e){
e.preventDefault();
pictureUpload();
return false;
});
function pictureUpload() {
var options = { url: 'chat/upload' }
$('#posts_form').ajaxForm(options);
}
但是,还有就是点击按钮(在控制台没有错误或者)没有反应 - 任何建议,就如何使这项工作
But there is no response to clicking on the button (no errors on console either) -- any suggestions how to make this work?
推荐答案
我想你可能需要包括并同时实现 beforeSubmit
和成功
选项进行文件上传的工作,因为在这个岗位建议:
jQuery的形式插件文件上传。
I think you may need to include and implement both beforeSubmit
and success
options for file upload to work, as suggested in this post:
Jquery form plugin file upload.
试试这个:
function pictureUpload() {
var options = {
url: 'chat/upload',
success: function() {},
beforeSubmit: function() {}
}
$('#posts_form').ajaxForm(options);
}
这篇关于如何触发提交使用jQuery表格时使用的类型没有呈现按钮=提交?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文