Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在Jasny Bootstrap中使用fileinput.js时,在选择文件后自动提交表单_Javascript_Jquery_Forms_Twitter Bootstrap_Jasny Bootstrap - Fatal编程技术网

Javascript 在Jasny Bootstrap中使用fileinput.js时,在选择文件后自动提交表单

Javascript 在Jasny Bootstrap中使用fileinput.js时,在选择文件后自动提交表单,javascript,jquery,forms,twitter-bootstrap,jasny-bootstrap,Javascript,Jquery,Forms,Twitter Bootstrap,Jasny Bootstrap,我正在使用中的功能 我的目标是让我的表单在用户选择文件后自动提交。我不希望他们必须点击“提交” 到目前为止,我已经尝试了两种方法和解决方案。这两种解决方案在不使用Jasny的fileinput.js时都能很好地工作,但在我使用它时却不能工作 document.getElementById("file").onchange = function() { document.getElementById("form").submit(); }; -- 当用户使用Jasny的fileinput

我正在使用中的功能

我的目标是让我的表单在用户选择文件后自动提交。我不希望他们必须点击“提交”

到目前为止,我已经尝试了两种方法和解决方案。这两种解决方案在不使用Jasny的fileinput.js时都能很好地工作,但在我使用它时却不能工作

document.getElementById("file").onchange = function() {
    document.getElementById("form").submit();
};
--

当用户使用Jasny的fileinput.js选择文件后,如何使表单自动提交?

从和中,您似乎需要侦听自定义
change.bs.fileinput
事件,而不是本机
change
事件。试着这样做:

$('#file').on('change.bs.fileinput', function () {
    $('#form').submit();
});
$('#file').on('change.bs.fileinput', function () {
    $('#form').submit();
});