java - 在表单提交时触发页面加载微调器

标签 java javascript jquery html forms

我正在尝试让 javascript spinner 来提交来自。我正在使用 spin.js 和我在此处找到的代码作为起点。

我们有 2 个选项来触发该 java:

  1. 提交表单时#submit-form
  2. 最后一次单击按钮时:按钮的唯一类是 .next-submit。

我不知道我哪里错了。

我不明白的另一件事是我是否需要在页面的 html 中使用 div #spinner,或者它是否是动态生成的。

<script src="http://www.purevisionmethod.com/js/spin.min.js"></script>

<script>
$(function() {
// Remember to use 'var'
var spinner_div = $('#spinner').get(0),
    spinner,
    opts = {
lines: 16, // The number of lines to draw
length: 23, // The length of each line
width: 5, // The line thickness
radius: 30, // The radius of the inner circle
corners: 100, // Corner roundness (0..1)
rotate: 0, // The rotation offset
direction: 1, // 1: clockwise, -1: counterclockwise
color: '#000', // #rgb or #rrggbb or array of colors
speed: 1, // Rounds per second
trail: 100, // Afterglow percentage
shadow: true, // Whether to render a shadow
hwaccel: true, // Whether to use hardware acceleration
className: 'spinner', // The CSS class to assign to the spinner
zIndex: 2e9, // The z-index (defaults to 2000000000)
top: '50%', // Top position relative to parent
left: '50%' // Left position relative to parent
    },
    showSpinner = function() {
        // Add 'lightbox-is-open' and 'lightbox-is-fixed' classes to HTML
        $('html').addClass('lightbox-is-open lightbox-is-fixed');

        // Remove 'hidden' class from '.glasspane'
        $('.glasspane').removeClass('hidden');

        // Show spinner
        if(spinner == null) {
            spinner = new Spinner(opts).spin(spinner_div);
        } else {
            spinner.spin(spinner_div);
        }

        // Submit form after 500ms
        var timer = window.setTimeout(function() {
            $('form').submit();
        }, 500);
    };

// Bind events
$('form').on('submit', function(e) {
    e.preventDefault();
    showSpinner();
});
$('.next-sbumit').on('click', function(e) {
    e.preventDefault();
    showSpinner();
});
$('select').on('change', showSpinner);
});
</script>

感谢您的帮助!!

最佳答案

我没有看到任何错误,但我注意到的一件事是这里有一个拼写错误:

$('.next-sbumit').on('click', function(e) {
    e.preventDefault();
    showSpinner();
});

next-sbumit 应该是 next-submit - 对吗?

关于java - 在表单提交时触发页面加载微调器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26538976/

相关文章:

java - 替换 Apache POI 中的表列值

javascript - 使用部分 View 将点击搜索转变为即时搜索

javascript - 在 Laravel 5 中使用 JQuery 从 href 中提取值时出错

php - 未捕获的语法错误 : Unexpected token < in one host but not in another for the same applicaiton

java - 未使用 NodeList 获取 XML 标记值

java - 将 websocket 连接同步到同一端点

javascript - curl获取的文件如何清除

php - Ignited Datatables - 在屏幕上显示记录

java - 如何摆脱 java URL 连接中的 "java.net.UnknownHostException"错误?

javascript - React JS 通过 props 访问数据 JSON