2014-05-23 3 views
-1

jQuery가 Magento에서 작동하지 않습니다. 나는 시간 카운트 다운을 보여주고 싶다. 작동하지 않습니다. 여기 내 site link입니다. 여기에 두 번째 id가 있으며 시차 값이 있습니다. 값을 인쇄하지만 JavaScript는 일일 거래와 같이 시간 수를 표시하지 않습니다. jquery가 magento에서 작동하지 않습니다.

<script type="text/javascript"> 
function updateClock(id) 
    { 
     var pid = id; 
     var currentSeconds1 = jQuery("#hello" + pid).val(); 
     mySeconds = currentSeconds1 - 1; 
     jQuery("#second" + pid).val(mySeconds); 
     alert(currentSeconds1); 
     if(mySeconds == 0){ 
      location.reload(); 
     } 
     else{ 
     var currentdays = Math.floor(mySeconds/86400); 
     var remainiday = mySeconds%86400; 
     var currentHours = Math.floor(remainiday/3600); 
     var myHours = remainiday%3600; 
     var currentMinutes = Math.floor(myHours/60); 
     var currentSeconds = myHours%60; 
     // Compose the string for display 
     currentHours = (currentHours < 10? '0' : '') + currentHours; 
     currentMinutes = (currentMinutes < 10? '0' : '') + currentMinutes; 
     currentSeconds = (currentSeconds < 10? '0' : '') + currentSeconds; 
     var currentTimeString = currentdays + ' Days ' + currentHours + "h : " +      currentMinutes + "m : " + currentSeconds +"s"; 
     var t = jQuery("#clock" + pid).html(currentTimeString); 
     } 
    } 
</script> 

그리고 젠토 코드 당신이뿐만 아니라 Prototype.js을 사용하고 jquery noconflict을 사용하지 않는 것 같다

<?php foreach ($productCollection-&gt;getItems() as $_product): ?> 
    <div class="time-left" style="font-weight: bold; color:#ff0000; font-size: 13px;">Time Left : 
    <span id="cl"></span> 
    <?php 
     $date1 =date("Y-m-d H:i:s", Mage::getModel('core/date')->timestamp(time())); 
     $date2 = date("Y-m-d 23:59:59", strtotime($_product->getSpecialToDate())); 
     $timeFirst = strtotime($date1); 
     $timeSecond = strtotime($date2); 
     echo $differenceInSeconds = $timeSecond - $timeFirst; 
    ?> 
    <input type="button" id="sec" value="<?php echo $differenceInSeconds ?>" /></div> 
    <div class="product-image"> 
    <a href="%3C?php%20echo%20$_product-%3EgetProductUrl()%20?%3E" 
    title="<?php echo $this->stripTags($this->getImageLabel($_product, &#39;small_image&#39;), null, true) ?>" class="product-image"> 
     <img src="%3C?php%20echo%20$this-%3Ehelper(&#39;catalog/image&#39;)-%3Einit($_product,%20&#39;small_image&#39;)-%3Eresize(161,123);%20?%3E" 
     width="161" height="123" alt="<?php echo $this->stripTags($this->getImageLabel($_product, &#39;small_image&#39;), null, true) ?>" /> 
    </a> 
    </div> 
    <span id="clock&lt;?php echo $_product-&gt;getId() ?&gt;"></span> 
    <?php 
     $date1 =date("Y-m-d H:i:s", Mage::getModel('core/date')->timestamp(time())); 
     $date2 = date("Y-m-d 23:59", strtotime($_product->getSpecialToDate())); 
     $timeFirst = strtotime($date1); 
     $timeSecond = strtotime($date2); 
     $differenceInSeconds = $timeSecond - $timeFirst; 
    ?> 
    <form> 
     <input type="hidden" id="hello" value="12" /> 
     <input type="hidden" id="second&lt;?php echo $_product-&gt;getId() ?&gt;" value="<?php echo $differenceInSeconds ?>" /> 
    </form> 
    <div class="product-info"> 
     <h3 class="product-name"> 
      <a href="%3C?php%20echo%20$_product-%3EgetProductUrl()%20?%3E" title="<?php echo $this->htmlEscape($_product->getName()) ?>"> 
       <?php echo $this->htmlEscape($_product->getName()) ?> 
      </a> 
     </h3> 
    </div> 
    <?php //if($isShowDescription == 1):?> 
<?php endforeach?> 
+2

updateClock 함수 앞에 jQuery.noConflict()를 사용하십시오. –

+0

두 가지 버전의 jquery로드가 없어야합니다. 제품 슬라이더에 의해 도입 된 버전을 제거해야합니다. – RichTea

답변

0

.

페이지 소스를 검토 한 결과 /*var jns = jQuery.noConflict();*/가 주석 처리되었습니다. 이것이 사실 일 수 있는지 확인하십시오.

var jQuery = jQuery.noConflict();으로 변경하여 사용하거나 요구 사항에 따라 사용할 수 있습니다. noConflict에 대해 별도의 Javascript 파일을 만들고 기본 jquery 라이브러리 바로 뒤에 포함시키는 것이 가장 좋습니다.

+0

나는 이것을 확인했지만 작동하지 않습니다. – user3667754

+0

페이지에서 jquery의 여러 버전을 사용하고있는 것으로 보입니다. 그러나 나는 당신이 타이머를 경계로 보여주고있는 것을 보았고 그것은 시간 또한 변화시키고 있습니다. – Vikram

관련 문제