2014-02-18 5 views
0

나는 프로젝트가 있고 미친 나를 몰아, 나는 geolocation/방향을 할 코드가 있고 everthing하지만 놀라운 일을 ios7와 나는 연구의 힙을 완료하고 그 이해 .click 이벤트 문제, 내 코드는 아래 있습니다.jQuery iPhone/ios7 클릭 이벤트 대 touch

$(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 --> 

는 지금은 감동과 연극을했다.

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

그리고 내가 가진 모든 오류 handleClicks is not defined과 행운 다른 해키 스크립트의 몇이었고, 나는이 문제를 해결하기 위해 기술 능력의 나의 끝입니다. 할 정말 제대로 작동

이 기능을 확인하십시오 :

+0

안녕하세요! 'handleClicks' 함수가'touche.min.js'에 정의되어 있다고 가정합니다. JS 스크립트가 올바르게로드 되었습니까? – Littm

+0

답장을 보내 주셔서 감사합니다. 사이트에서 jquery-1.11.0.min.js를 사용하고 있습니다.이 슬라이더는 이미지 슬라이더로 잘 작동하므로 이미지가 잘 보이고 작동하는 것으로 알고 있습니다. – webmonkey237

+0

다른 스크립트와 충돌 할 수 있습니까? – webmonkey237

답변

0

내가 어떻게 파일 트리를보고하지 않으며, 당신이, 그리고 사촌의 파일을 포함하는 방법. 내 말은이 같은 수행 기능이 제대로 작동에 대해

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

을 그리고 handleClicks 기능에 넣어 alert('something') 그것은 당신에게 감동을 첨부가 충돌 및 파일이

더 나은 성공적으로 포함되지 않은, 우리가 있는지 확인합니다 .min.js 및 혈관 고리는

0

당신이 나를

0

도서관에 근무 fastbutton 라이브러리를 시도 할 수 귀하의 문제를 다시 시도 할 것입니다 Touche.js 는 jQuery에 적용된 클릭 이벤트를 가져와 터치를 지원하는 장치의 "touchend"이벤트로 자동 매핑하는 라이브러리입니다.

따라서 함수를 handleClicks으로 정의하고 버튼에 바인딩하면됩니다.

그러면 라이브러리는 click 이벤트를 touch 이벤트로 다시 매핑해야합니다.