简体   繁体   English

表单中的“提交”按钮不适用于Iscroll

[英]Submit button in form doesn't work with Iscroll

i use Iscroll 5, everything is working as i want except one thing. 我使用Iscroll 5,除了一件事外,一切都按我的要求工作。 I can't click on a submit button in a form, nothing happens. 我无法单击表单中的“提交”按钮,没有任何反应。

This is my code, i tried many things but i don't know how can i fix it. 这是我的代码,我尝试了很多事情,但我不知道该如何解决。

<script type="text/javascript">
var scroll;
function loaded() {
        scroll = new IScroll('#contenu', {
        tap:true,
        desktopCompatibility: true,
        scrollbars: false,
        interactiveScrollbars: true,
        freeScroll: true,
        scrollX: true,
        scrollY: true,
        momentum: false,
        mouseWheel: true,
        click: true,
        useTransform: false,
            onBeforeScrollStart: function (e) {
                var target = e.target;
                while (target.nodeType != 1) target = target.parentNode;    
                if (target.tagName != 'SELECT' && target.tagName != 'INPUT' && target.tagName != 'TEXTAREA'  && target.tagName != 'BUTTON') {
                    e.preventDefault();
                }   

            }
    });
}

//disables browser mouse scrolling
if (window.addEventListener) {
    window.addEventListener('DOMMouseScroll', wheel, false);
}

function wheel(event) {
    event.preventDefault();
    event.returnValue = false;
}

window.onmousewheel = document.onmousewheel = wheel;
</script>

Dude your are my hero your fix work well but I have made it some improvement because the default handler was different :) 老兄,您是我的英雄,您的修复工作正常,但由于默认处理程序有所不同,我对此进行了一些改进:)

So I replace normal click event on iscroll line 1565 因此,我替换了iscroll 1565行上的正常点击事件

case 'click':
            if ( !e._constructed ) {
                e.preventDefault();
                e.stopPropagation();
            }
            break;

by this line and now I have no problem my send and reset input work well ty dude ! 通过这一行,现在我没问题了,我的发送和重置输入工作正常,伙计!

case 'click':
        if ( !e._constructed ) {
        if ( !e._constructed && target.type != "submit") {
            e.preventDefault();
            e.stopPropagation();
        }
         e.preventDefault();
         e.stopPropagation();
        }
        break;

this is working well on my ipad Android phone and chrome Firefox not tested on IE, but the inspector show me an error he say that target is not define? 这在我的ipad Android手机和未在IE上经过测试的Chrome Firefox上运行良好,但是检查器向我显示了一个错误,他说目标未定义?

Someone have an idea for fixing that :p? 有人有想法解决:p?

ps for the author : You must put click to false in your iscroll déclaration else you will have a bug and people cant write correcty text in input type text ! ps给作者的提示:您必须在iscroll声明中将click设置为false,否则会出现错误,并且人们无法在输入类型文本中输入正确的文本!

i fixed it, i could help someone, 我修好了,我可以帮助别人,

case 'click':
            if ( !e._constructed ) {
            if ( !e._constructed && target.type != "submit") {
                e.preventDefault();
                e.stopPropagation();
            }
            }

in iscroll.js. 在iscroll.js中。

Replace below line of code from iscroll5 js file 替换下面的iscroll5 js文件中的代码行

if ( !e._constructed ) {
                    e.preventDefault();
                    e.stopPropagation();
}

with

if ( !e._constructed && e.target.type != 'submit' ) {
                    e.preventDefault();
                    e.stopPropagation();
}

I was having same issue. 我有同样的问题。 Other answers did not fix my issue. 其他答案不能解决我的问题。

Fixed it with removing the click option click: true altogether. 移除了click选项click: true完全修复了该问题。

From the documentation : 文档中

options.click options.click

To override the native scrolling iScroll has to inhibit some default browser behaviors, such as mouse clicks. 要覆盖本机滚动,iScroll必须禁止某些默认浏览器行为,例如鼠标单击。 If you want your application to respond to the click event you have to explicitly set this option to true. 如果希望您的应用程序响应单击事件,则必须将该选项显式设置为true。 Please note that it is suggested to use the custom tap event instead (see below). 请注意,建议改用自定义点击事件(见下文)。

Default: false 默认值:false

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM