Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/470.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/68.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 jQuery iPhone/ios7点击事件与触摸屏_Javascript_Jquery_Ios7 - Fatal编程技术网

Javascript jQuery iPhone/ios7点击事件与触摸屏

Javascript jQuery iPhone/ios7点击事件与触摸屏,javascript,jquery,ios7,Javascript,Jquery,Ios7,我有一个项目,它让我发疯,我有代码做地理定位/方向,它在每件事情上都非常好,但ios7和我做了大量的研究,我知道这是一个问题。点击事件,我的代码如下 $(document).ready(function () { var startingLocation; var destination = "20 Papanui Rd, Christchurch Central, Christchurch 8011, New Zealand"; // replace this with any

我有一个项目,它让我发疯,我有代码做地理定位/方向,它在每件事情上都非常好,但ios7和我做了大量的研究,我知道这是一个问题。点击事件,我的代码如下

$(document).ready(function () {
    var startingLocation;
    var destination = "20 Papanui Rd, Christchurch Central, Christchurch 8011, New Zealand"; // replace this with any destination
    $('.get-directions').click(function (e) {
        e.preventDefault();

        // check if browser supports geolocation
        if (navigator.geolocation) {
            // get user's current position
            navigator.geolocation.getCurrentPosition(function (position) {
                // get latitude and longitude
                var latitude = position.coords.latitude;
                var longitude = position.coords.longitude;
                startingLocation = latitude + "," + longitude;

                // send starting location and destination to goToGoogleMaps function
                goToGoogleMaps(startingLocation, destination);
            });
        }

        // fallback for browsers without geolocation
        else {
            // get manually entered postcode
            startingLocation = $('.manual-location').val();

            // if user has entered a starting location, send starting location and destination to goToGoogleMaps function
            if (startingLocation != '') {
                goToGoogleMaps(startingLocation, destination);
            }
                // else fade in the manual postcode field
            else {
                $('.no-geolocation').fadeIn();
            }
        }

        // go to Google Maps function - takes a starting location and destination and sends the query to Google Maps
        function goToGoogleMaps(startingLocation, destination) {
            window.location = "https://maps.google.com/maps?saddr=" + startingLocation + "&daddr=" + destination;
        }
    });
});
HTML:

<!--#container -->
<div id="mapcontainer">
    <div class="no-geolocation">
        <p class="warning">Your browser does not support Geolocation. Please enter your  postcode and click the button again.</p>
        <input type="text" placeholder="Enter postcode or address" class="manual-location">
    </div>
    <a href="#" class="get-directions">Give me directions</a>
</div>
<!-- /#container -->

您的浏览器不支持地理定位。请输入您的邮政编码,然后再次单击按钮

现在我和Touche玩了一场

<script type='text/javascript' src="files/scripts/touche.min.js"></script>
<script>
$(document).ready(function() {
    $('.get-directions').on('click', handleClicks);
});
</script>

$(文档).ready(函数(){
$('.get directions')。在('click',handleclick)上;
});

我得到的只是一个错误
handleClicks没有定义
和一些其他的黑客脚本,运气不好,我已经没有能力解决这个问题了。

我不知道你的文件树是如何的,你是如何包含文件的,因为:

尝试检查此功能,确保它真正正常工作。我是说,像这样做:

<script type='text/javascript' src="files/scripts/touche.min.js"></script>
<script>
handleClicks();
$(document).ready(function() {
    $('.get-directions').on('click', handleClicks);
});
</script>

handleClicks();
$(文档).ready(函数(){
$('.get directions')。在('click',handleclick)上;
});
并输入
handleClicks
function
alert('something')
它将确保我们的功能正常工作,并没有冲突和文件已成功包括


更好的方法是,连接touche.min.js,ppls可以尝试重新创建您的问题

您可以尝试库它对我有用

touche.js
是一个库,用于将您的点击事件应用于jQuery,并将它们以静默方式重新映射到支持触摸的设备的“touchend”事件

因此,您只需定义函数
handleClicks
,并将其绑定到按钮,就像它是一个单击事件一样


然后,库应将单击事件重新映射到触摸事件。

Hi!我假设函数
handleClicks
是在
touch.min.js
中定义的。JS脚本加载是否正确?感谢您的回复,该网站正在使用jquery-1.11.0.min.JS,它与图像滑块配合良好,因此我知道它在那里并正常工作。它是否与其他脚本冲突?我不这么认为。。。胡姆。。。你有到js script
touch.min.js
的链接吗?这样我可以试着重现你的问题。页面本身是: