2016-03-17 71 views
0

我們使用以下腳本,並在控制檯我們得到這些錯誤:未捕獲的ReferenceError:jQuery是不是在Magento站點定義

我們有Magento站點1.9.0

我們提供了一個選項來保存值從前端。

這裏在前端,值不保存在數據庫中。

這是jQuery的錯誤問題?我跟着第一個回答這個鏈接:Uncaught ReferenceError: $ is not defined?但didt我

enter image description here

HTML代碼

<span class="label qty" id="valueqty_<?php echo $assinproducts->getId(); ?>"> 
     <?php echo intval($assinproducts['qty']); ?> 
    </span> 

    <input type = "text" id = "qty_<?php echo $assinproducts->getId(); ?>" onkeydown="validateNumbers(event)" 
    name="stock" value="<?php echo intval($assinproducts['qty']); ?>" style="display:none;"/> 

    <span class="label wk_action" id="edit_link_<?php echo $assinproducts->getId(); ?>"> 
     <img onclick="showField('<?php echo $assinproducts->getId(); ?>'); return false;" 
     src="<?php echo $this->getSkinUrl('marketplace/images/icon-edit.png'); ?>"/> 
    </span> 

    <p id="updatedqty_<?php echo $assinproducts->getId(); ?>" style = "display:none;color:red;">Updated</p><br/> 

    <button id="update_button_<?php echo $assinproducts->getId(); ?>" class="button wk_mp_btn1" 
    onclick="updateField('<?php echo $assinproducts->getId(); ?>',<?php echo intval($assinproducts['qty']); ?>); return false;" style="display:none" > 
     <span> 
      <span style="font-size:12px;"><?php echo $helper->__('Update') ?></span> 
     </span> 
    </button> 

    <button id="reset_button_<?php echo $assinproducts->getId(); ?>" type="reset" class="cancel" 
    onclick="hideReset('<?php echo $assinproducts->getId(); ?>'); return false;" style="display:none"></button> 

腳本

<script type="text/javascript" src="/test/wp-content/themes/child/script/jquery.jcarousel.min.js"></script> 

<!-- to remove console js errors end --> 


<script language="JavaScript" type="text/javascript" src="/js/jquery-1.2.6.min.js"></script> 
<script language="JavaScript" type="text/javascript" src="/js/jquery-ui-personalized-1.5.2.packed.js"></script> 
<script language="JavaScript" type="text/javascript" src="/js/sprinkle.js"></script> 
<script language="JavaScript" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0-beta1/jquery.min.js"></script> 


<script language="JavaScript" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0-beta1/jquery.min.js"> 
    function validateNumbers(e) 
    { 
     if (jQuery.inArray(e.keyCode, [46, 8, 9, 27, 13, 110, 190]) !== -1 || 
      // Allow: Ctrl+A, Command+A 
      (e.keyCode == 65 && (e.ctrlKey === true || e.metaKey === true)) || 
      // Allow: home, end, left, right, down, up 
      (e.keyCode >= 35 && e.keyCode <= 40)) { 
       // let it happen, don't do anything 
       return; 
     } 

     // Ensure that it is a number and stop the keypress 
     if ((e.shiftKey || (e.keyCode < 48 || e.keyCode > 57)) && (e.keyCode < 96 || e.keyCode > 105)) { 
      e.preventDefault(); 
     } 
    } 

    var $wk_jq = jQuery.noConflict(); 

    (function($wk_jq){ 
      $wk_jq("#special_from_date").datepicker({dateFormat: "yy-mm-dd"}); 
      $wk_jq("#special_to_date").datepicker({dateFormat: "yy-mm-dd"}); 
      $wk_jq('#mpselecctall').click(function(event) { 
      if(this.checked) { 
       $wk_jq('.mpcheckbox').each(function() { 
        this.checked = true;  
       }); 
      }else{ 
       $wk_jq('.mpcheckbox').each(function() { 
        this.checked = false;   
       });   
      } 
     }); 

     $wk_jq('body').delegate('.mp_edit','click',function(){ 
      var id=$wk_jq(this).attr("data-type"); 
        var dicision=confirm('<?php echo $helper->__(" Are you sure you want to edit this product ? ")?>'); 
        if(dicision==true){   
          var $type_id=$wk_jq(this).attr('data-type');     
          window.location = "<?php echo $this->getUrl('mpassignproduct/index/edit/') ?>".concat("id/",id);  
        } 
     }); 

     $wk_jq('.mp_delete').click(function(){ 
        var id=$wk_jq(this).attr("data-type"); 
        var dicisionapp=confirm('<?php echo $helper->__(" Are you sure you want to delete this product ? ")?>'); 
        if(dicisionapp==true) 
          window.location = "<?php echo $this->getUrl('mpassignproduct/index/delete/') ?>".concat("id/",id); 
      }); 

      $wk_jq('#mass_delete_butn').click(function(e){ 
        var flag =0; 
        $wk_jq('.mpcheckbox').each(function(){ 
          if (this.checked == true){ 
            flag =1; 
          } 
        }); 
        if (flag == 0){ 
          alert("<?php echo $helper->__(' No Checkbox is checked') ?>"); 
          return false; 
        } 
        else{ 
          var dicisionapp=confirm('<?php echo $helper->__(" Are you sure you want to delete these product ? ")?>'); 
          if(dicisionapp==true){ 
            $wk_jq('#form-customer-product-delete').submit(); 
          }else{ 
            return false; 
          } 
        } 
      }); 
    })($wk_jq); 


    function hideReset(product_id) 
    { 
     var qtyId='#qty_'+ product_id; 
     var editLink="#edit_link_"+ product_id; 
     var updateButton="#update_button_"+ product_id; 
     var resetButton="#reset_button_"+ product_id; 

     $wk_jq(qtyId).hide(); 
     $wk_jq(editLink).show(); 
     $wk_jq(updateButton).hide(); 
     $wk_jq(resetButton).hide(); 
    } 

    function showField(product_id) 
    { 
     var qtyId   = '#qty_'+ product_id; 
     var editLink  = "#edit_link_"+ product_id; 
     var updateButton = "#update_button_"+ product_id; 
     var resetButton  = "#reset_button_"+ product_id; 

     $wk_jq(qtyId).show(); 
     $wk_jq(editLink).hide(); 
     $wk_jq(updateButton).show(); 
     $wk_jq(updateButton).prop('disabled', false);//just in case 
     $wk_jq(resetButton).show(); 

     return false; 
    } 



    function updateField(product_id,assignqty) 
    { 

    // alert("Hello! I am an alert box!!"); 
     var qtyId   = '#qty_'+ product_id; 
     var valueId   = '#valueqty_'+ product_id; 
     var updatedqty  = '#updatedqty_'+ product_id; 
     var editLink  = "#edit_link_"+ product_id; 
     var updateButton = "#update_button_"+ product_id; 
     var resetButton  = "#reset_button"+ product_id; 
     var url    = '<?php echo Mage::getUrl('marketplace/marketplaceaccount/updateField/')?>'; 

     $wk_jq(qtyId).toggle(); 
     $wk_jq(editLink).hide(); 
     $wk_jq(updateButton).show(); 
     $wk_jq(resetButton).show(); 

     $qty = $wk_jq(qtyId).val(); 
     jQuery(valueId).html($qty); 
     hideReset(product_id); 

     var tmpQty = assignqty+parseInt($qty) ; 

     new Ajax.Request(url, { 
      method: 'post', 
      parameters: {id: product_id, qty: tmpQty}, 
      onComplete: function (transport) { 
      // alert(tmpQty); 
       jQuery(priceId).val($price);     
     jQuery(updatedqty).show().delay(2000).fadeOut(); 
       $updateButton.prop('disabled', false); 
      } 
     }); 
    } 






</script> 

完整的HTML和JS代碼工作的fi樂:

<script type="text/javascript" src="/test/wp-content/themes/child/script/jquery.jcarousel.min.js"></script> 

<!-- to remove console js errors end --> 


<script language="JavaScript" type="text/javascript" src="/js/jquery-1.2.6.min.js"></script> 
<script language="JavaScript" type="text/javascript" src="/js/jquery-ui-personalized-1.5.2.packed.js"></script> 
<script language="JavaScript" type="text/javascript" src="/js/sprinkle.js"></script> 
<script language="JavaScript" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0-beta1/jquery.min.js"></script> 








<?php 
$helper=Mage::helper('mpassignproduct'); 
$isPartner= Mage::getModel('marketplace/userprofile')->isPartner(); 
if($isPartner==1){ ?> 
    <script type="text/javascript"> 
    if (typeof jQuery == 'undefined'){ 
     document.write(unescape("%3Cscript src='http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js' type='text/javascript'%3E%3C/script%3E")); 
    } 
    </script> 
    <script src="//code.jquery.com/ui/1.10.3/jquery-ui.js"></script> 
    <link rel="stylesheet" href="//code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" /> 
    <div> 
     <div class="page-title"> 
      <h1><?php echo $helper->__('My Assign Product List') ?></h1> 
     </div> 
     <div class="wk_mp_design"> 
      <div class="block block-account"> 
       <div class="block-title"> 
        <strong><span><h4><?php echo $helper->__('My Assign Product List'); ?></h4></span></strong> 
       </div> 
      </div> 
      <div class="fieldset wk_mp_fieldset"> 
       <div class="grid"> 
        <div class="hor-scroll"> 
         <?php 
          if(count($this->getCollection())==0): ?>   
           <div class="fieldset wk_mp_fieldset"> 
            <div class="wk_emptymsg"> 
             <?php echo $helper->__('No Product Available') ?> 
            </div> 
           </div> 
         <?php else: ?> 
          <form action="<?php echo Mage::helper('core/url')->getCurrentUrl();?>" method="post"> 
           <table cellspacing="0" class="border wk_mp_list_table"> 
            <thead> 
             <tr id="wk_mp_tr_heading"> 
              <th><span><?php echo $helper->__('Product Name') ?></span></th> 
              <th><span><?php echo $helper->__('Date') ?></span></th> 
              <th><span><?php echo $helper->__('Product Status') ?></span></th> 
              <th><span>&nbsp;</span></th> 
             </tr> 
            </thead> 
            <tbody class="wk_mp_body"> 
             <tr> 
              <td> 
               <input type="text" class="input-text" name="s" placeholder='<?php echo $helper->__('Search by product name') ?>' value="<?php echo $this->getRequest()->getParam('s')?>"/> 
              </td> 
              <td> 
               <span class="wk_mp_td_span"> 
                <?php echo $helper->__('From: ') ?> 
                <input name="from_date" id="special_from_date" class="input-text" value="<?php echo $this->getRequest()->getParam('from_date')?>" /> 
               </span>        
               <span class="wk_mp_td_span"> 
                <?php echo $helper->__('To: ') ?> 
                <input name="to_date" id="special_to_date" class="input-text" value="<?php echo $this->getRequest()->getParam('to_date')?>" /> 
               </span> 
              </td> 
              <td> 
               <select name="prostatus" class="input-text"> 
                <option value=""><?php echo $helper->__('All') ?></option> 
                <option value="1" <?php if($this->getRequest()->getParam('prostatus') == 1) echo 'selected="selected"'?>> 
                 <?php echo $helper->__('Approved') ?> 
                </option> 
                <option value="2" <?php if($this->getRequest()->getParam('prostatus') == 2) echo 'selected="selected"'?>> 
                 <?php echo $helper->__('Unapproved') ?> 
                </option> 
               </select> 
              </td> 
              <td> 
               <button class="button" title="Save" type="submit"> 
                <span><span><span><?php echo $helper->__('Submit') ?></span></span></span> 
               </button> 
              </td> 
             </tr> 
            </tbody> 
           </table> 
          </form> 
          <form name="formmassdelete" id="form-customer-product-delete" method="post" action="<?php echo $this->getUrl('mpassignproduct/index/massdeletepro') ?>"> 
           <input type="hidden" name="form_key" value="<?php echo Mage::getSingleton('core/session')->getFormKey(); ?>" /> 
           <button id="mass_delete_butn" style="float: left;padding: 5px 5px 5px 0;" type="submit" title="Delete Sellers" class="button"> 
            <span><span>Delete Products</span></span> 
           </button> 
           <table cellspacing="0" class="border wk_mp_list_table wk_mp_list_container_table"> 
            <thead> 
             <tr class="wk_content"> 
              <th class="wk_check_first_td"> 
               <span><input type="checkbox" id="mpselecctall" value="all" name="mpselecctall"></span> 
              </th> 
              <th class="wk_first_td"> 
               <span class="label "><?php echo $helper->__('Product Name')?></span> 
              </th> 
              <th> 
               <span class="label name"><?php echo $helper->__('Price')?></span> 
              </th> 

              <th> 
               <span class="label name"><?php echo $helper->__('SKU')?></span> 
              </th> 

              <th> 
               <span class="label name"><?php echo $helper->__('Delivery Time')?></span> 
              </th> 

              <th> 
               <span class="label name"><?php echo $helper->__('Replacement Guarantee')?></span> 
              </th> 

              <th> 
               <span class="label qty"><?php echo $helper->__('Status')?></span> 
              </th> 


              <th> 
               <span class="label qty"><?php echo $helper->__('Qty.')?></span> 
              </th> 


              <th> 
               <span class="label qty"><?php echo $helper->__('Condition')?></span> 
              </th> 

              <th> 
               <span class="label"><?php echo $helper->__('Action')?></span> 
              </th> 

             </tr> 
            </thead> 

            <tbody> 
             <?php foreach($this->getCollection() as $assinproducts): ?> 
              <?php $products=Mage::getModel('catalog/product')->load($assinproducts->getProductId()); ?> 
              <tr class="wk_row_view "> 
               <td class="wk_check_first_td"> 
                <span> 
                 <input type="checkbox" value="<?php echo $assinproducts->getMpassignproductId(); ?>" class="mpcheckbox" name="product_mass_delete[]"> 
                </span> 
               </td> 
               <td class="wk_first_td"> 
                <span class="label name" title="<?php echo $products->getName(); ?>"> 
                 <?php 
                  $productname=strlen($products->getName())>7?substr($products->getName(),0,7)."..":$products->getName(); 
                  echo $products->getName(); 
                 ?> 
                </span> 
               </td> 
               <td> 
                <span class="label price"> 
                 <?php echo Mage::helper('core')->currency($assinproducts->getPrice(), true, false);?> 
                </span> 
               </td> 

               <td> 
                <span class="label sku"> 
                 <?php echo $assinproducts->getsku() ?> 
                </span> 
               </td> 

               <td> 
                <span class="label replacement"> 
                 <?php echo $assinproducts->getdeliverytime() ?> 
                </span> 
               </td> 

               <td> 
                <span class="label delivery"> 
                 <?php echo $assinproducts->getreplacement() ?> 
                </span> 
               </td> 


               <td> 
                <span class="label pro_status"> 
                 <?php if($assinproducts['flag']==1): ?> 
                  <?php echo Mage::helper('mpassignproduct')->__('Approved')?> 
                 <?php else: ?> 
                  <?php echo Mage::helper('mpassignproduct')->__('Un-Approved')?> 
                 <?php endif; ?> 
                </span> 


    </td> 


<td> 
    <span class="label qty" id="valueqty_<?php echo $assinproducts->getId(); ?>"> 
     <?php echo intval($assinproducts['qty']); ?> 
    </span> 

    <input type = "text" id = "qty_<?php echo $assinproducts->getId(); ?>" onkeydown="validateNumbers(event)" 
    name="stock" value="<?php echo intval($assinproducts['qty']); ?>" style="display:none;"/> 

    <span class="label wk_action" id="edit_link_<?php echo $assinproducts->getId(); ?>"> 
     <img onclick="showField('<?php echo $assinproducts->getId(); ?>'); return false;" 
     src="<?php echo $this->getSkinUrl('marketplace/images/icon-edit.png'); ?>"/> 
    </span> 

    <p id="updatedqty_<?php echo $assinproducts->getId(); ?>" style = "display:none;color:red;">Updated</p><br/> 

    <button id="update_button_<?php echo $assinproducts->getId(); ?>" class="button wk_mp_btn1" 
    onclick="updateField('<?php echo $assinproducts->getId(); ?>',<?php echo intval($assinproducts['qty']); ?>); return false;" style="display:none" > 
     <span> 
      <span style="font-size:12px;"><?php echo $helper->__('Update') ?></span> 
     </span> 
    </button> 

    <button id="reset_button_<?php echo $assinproducts->getId(); ?>" type="reset" class="cancel" 
    onclick="hideReset('<?php echo $assinproducts->getId(); ?>'); return false;" style="display:none"></button> 
</td> 



               <td> 
                <span class="label"> 
                 <?php 
                  if($assinproducts['product_condition']=='new') 
                   echo Mage::helper('mpassignproduct')->__('New'); 
                  else 
                   echo Mage::helper('mpassignproduct')->__('Used'); 
                 ?> 
                </span> 
               </td> 
               <td> 
                <span class="label wk_action"> 
                 <img src="<?php echo $this->getSkinUrl('marketplace/images/icon-edit.png'); ?>" data-type="<?php echo $assinproducts->getMpassignproductId(); ?>" alt="<?php echo $helper->__('Edit')?>" title="<?php echo $helper->__('Edit')?>" class="mp_edit"/> 
                 <img data-type="<?php echo $assinproducts->getMpassignproductId(); ?>" src="<?php echo $this->getSkinUrl('marketplace/images/icon-trash.png'); ?>" alt="<?php echo $helper->__('Delete')?>" title="<?php echo $helper->__('Delete')?>" class="mp_delete"/> 
                </span> 
               </td>      
              </tr>    
             <?php endforeach; ?>        
            </tbody> 

           </table> 
          </form> 
         <?php endif; ?> 
        </div> 
       </div> 
       <?php echo $this->getPagerHtml(); ?> 
      </div> 
     </div> 
     <div class="buttons-set"> 
      <p class="back-link"> 
       <a href="javascript:;" onclick="javascript: window.history.back();" class="left">&laquo; <?php echo Mage::helper('marketplace')->__('Back') ?></a> 
      </p> 
     </div> 
    </div> 
<?php }else{ 
    echo "<h2 class='wk_new_msg'>".$helper->__("To BECOME SELLER PLEASE CONTACT TO ADMIN.")."</h2>"; 
}?> 

<!-- to remove console js errors --> 


<script language="JavaScript" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0-beta1/jquery.min.js"> 
    function validateNumbers(e) 
    { 
     if (jQuery.inArray(e.keyCode, [46, 8, 9, 27, 13, 110, 190]) !== -1 || 
      // Allow: Ctrl+A, Command+A 
      (e.keyCode == 65 && (e.ctrlKey === true || e.metaKey === true)) || 
      // Allow: home, end, left, right, down, up 
      (e.keyCode >= 35 && e.keyCode <= 40)) { 
       // let it happen, don't do anything 
       return; 
     } 

     // Ensure that it is a number and stop the keypress 
     if ((e.shiftKey || (e.keyCode < 48 || e.keyCode > 57)) && (e.keyCode < 96 || e.keyCode > 105)) { 
      e.preventDefault(); 
     } 
    } 

    var $wk_jq = jQuery.noConflict(); 

    (function($wk_jq){ 
      $wk_jq("#special_from_date").datepicker({dateFormat: "yy-mm-dd"}); 
      $wk_jq("#special_to_date").datepicker({dateFormat: "yy-mm-dd"}); 
      $wk_jq('#mpselecctall').click(function(event) { 
      if(this.checked) { 
       $wk_jq('.mpcheckbox').each(function() { 
        this.checked = true;  
       }); 
      }else{ 
       $wk_jq('.mpcheckbox').each(function() { 
        this.checked = false;   
       });   
      } 
     }); 

     $wk_jq('body').delegate('.mp_edit','click',function(){ 
      var id=$wk_jq(this).attr("data-type"); 
        var dicision=confirm('<?php echo $helper->__(" Are you sure you want to edit this product ? ")?>'); 
        if(dicision==true){   
          var $type_id=$wk_jq(this).attr('data-type');     
          window.location = "<?php echo $this->getUrl('mpassignproduct/index/edit/') ?>".concat("id/",id);  
        } 
     }); 

     $wk_jq('.mp_delete').click(function(){ 
        var id=$wk_jq(this).attr("data-type"); 
        var dicisionapp=confirm('<?php echo $helper->__(" Are you sure you want to delete this product ? ")?>'); 
        if(dicisionapp==true) 
          window.location = "<?php echo $this->getUrl('mpassignproduct/index/delete/') ?>".concat("id/",id); 
      }); 

      $wk_jq('#mass_delete_butn').click(function(e){ 
        var flag =0; 
        $wk_jq('.mpcheckbox').each(function(){ 
          if (this.checked == true){ 
            flag =1; 
          } 
        }); 
        if (flag == 0){ 
          alert("<?php echo $helper->__(' No Checkbox is checked') ?>"); 
          return false; 
        } 
        else{ 
          var dicisionapp=confirm('<?php echo $helper->__(" Are you sure you want to delete these product ? ")?>'); 
          if(dicisionapp==true){ 
            $wk_jq('#form-customer-product-delete').submit(); 
          }else{ 
            return false; 
          } 
        } 
      }); 
    })($wk_jq); 


    function hideReset(product_id) 
    { 
     var qtyId='#qty_'+ product_id; 
     var editLink="#edit_link_"+ product_id; 
     var updateButton="#update_button_"+ product_id; 
     var resetButton="#reset_button_"+ product_id; 

     $wk_jq(qtyId).hide(); 
     $wk_jq(editLink).show(); 
     $wk_jq(updateButton).hide(); 
     $wk_jq(resetButton).hide(); 
    } 

    function showField(product_id) 
    { 
     var qtyId   = '#qty_'+ product_id; 
     var editLink  = "#edit_link_"+ product_id; 
     var updateButton = "#update_button_"+ product_id; 
     var resetButton  = "#reset_button_"+ product_id; 

     $wk_jq(qtyId).show(); 
     $wk_jq(editLink).hide(); 
     $wk_jq(updateButton).show(); 
     $wk_jq(updateButton).prop('disabled', false);//just in case 
     $wk_jq(resetButton).show(); 

     return false; 
    } 



    function updateField(product_id,assignqty) 
    { 

    // alert("Hello! I am an alert box!!"); 
     var qtyId   = '#qty_'+ product_id; 
     var valueId   = '#valueqty_'+ product_id; 
     var updatedqty  = '#updatedqty_'+ product_id; 
     var editLink  = "#edit_link_"+ product_id; 
     var updateButton = "#update_button_"+ product_id; 
     var resetButton  = "#reset_button"+ product_id; 
     var url    = '<?php echo Mage::getUrl('marketplace/marketplaceaccount/updateField/')?>'; 

     $wk_jq(qtyId).toggle(); 
     $wk_jq(editLink).hide(); 
     $wk_jq(updateButton).show(); 
     $wk_jq(resetButton).show(); 

     $qty = $wk_jq(qtyId).val(); 
     jQuery(valueId).html($qty); 
     hideReset(product_id); 

     var tmpQty = assignqty+parseInt($qty) ; 

     new Ajax.Request(url, { 
      method: 'post', 
      parameters: {id: product_id, qty: tmpQty}, 
      onComplete: function (transport) { 
      // alert(tmpQty); 
       jQuery(priceId).val($price);     
     jQuery(updatedqty).show().delay(2000).fadeOut(); 
       $updateButton.prop('disabled', false); 
      } 
     }); 
    } 






</script> 

<style> 
.social-icons { 
     display:none !important; 
    } 
</style> 

回答

3

您的錯誤消息清楚地表明您的jQuery變量未定義。簡單地改變這種

var $wk_jq = jQuery.noConflict();

var $wk_jq = $.noConflict();

+0

感謝您的支持...... – fresher

1

,你所面對的錯誤是因爲你沒有給jQuery庫的一條合適的路徑,這就是爲什麼你的頁面是沒有得到jQuery的,因此它是示值誤差jQuery is not defined$ is not defined

+0

我是新來的JS。請通過在我的代碼中提供適當的jQuery庫路徑,爲我提供更新的代碼。 – fresher

+0

你可以使用在線圖書館:https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0-beta1/jquery.min.js –

+0

這將肯定會解決你的錯誤,雖然它不建議使用在線庫中的任何應用程序,但這將工作 –

2

uses by default. Since it uses jquery, it is recommended to stick with this default jquery package.

默認jquery從目錄js/lib/jquery/jquery-1.10.2.min.js正在加載。如果您進一步檢查,您還可以看到另一個jquery文件(位於/js/lib/jquery/noconflict.js),該文件用於避免jQuery衝突。這是該js文件的內容。

// Avoid PrototypeJS conflicts, assign jQuery to $j instead of $ 
var $j = jQuery.noConflict(); 

看看評論。它說,你應該使用$j而不是$。這意味着爲了避免衝突,你需要確保三件事情。

1)不要使用新的jquery包,使用默認的包。你不打擾這一步。 Magento會爲你加載它的jquery。所以請不要再添加jquery。

2)確保noconflict.js正在默認的jquery庫之後加載。這也由默認的Magento管理。 3)現在添加你的放大鏡庫js文件(如果有的話)(可選步驟,僅當放大鏡技術依賴任何jquery包時才需要)。

4)使用您的自定義js文件,它使用放大鏡js庫。在這個文件中,而不是使用$,你應該在任何地方都使用$j。這樣Magento不會發生任何jQuery衝突。

+0

我正在檢查現在。會很快讓你知道。 – fresher

+0

我沒有發現js/lib文件夾下的jquery文件夾,我正在從網站的根目錄進行檢查。 可以請你確認我的路徑。 – fresher

+0

[Magento Mirror /js/lib/jquery](https://github.com/OpenMage/magento-mirror/tree/magento-1.9/js/lib/jquery) - 可能您的magento安裝不乾淨!? – rayphi

1

正如我所見,jQuery.js就在carrousal.js文件的下面。請將jQuery放在頁面頂部,然後使用no.Conflict,希望這可以幫助你。

Thnaks

+0

我會盡力...... – fresher

+0

希望這會對你有用 –

+0

對不起,我沒有在我的文件中找到這些文本:'jQuery .js&carrousal.js'你請用完整的代碼更新答案。 – fresher

2

有可能您沒有在網頁中加載jQuery。而不是在頁面中包含jQuery,你應該通過佈局xml來完成。你甚至可以通過將它添加到你的app/design/frontend/package/theme/layout中的page.xml來完成前端的每一頁。一旦你確定你的jQuery加載的頁面上,你可以選擇是使用noconflict有你在,或只是更換「$」與工作jQuery的。請確保你是洽,我在你的代碼注意到了這一點:

function updateField(product_id,assignqty) 
{ 

// alert("Hello! I am an alert box!!"); 
    var qtyId   = '#qty_'+ product_id; 
    var valueId   = '#valueqty_'+ product_id; 
    var updatedqty  = '#updatedqty_'+ product_id; 
    var editLink  = "#edit_link_"+ product_id; 
    var updateButton = "#update_button_"+ product_id; 
    var resetButton  = "#reset_button"+ product_id; 
    var url    = '<?php echo Mage::getUrl('marketplace/marketplaceaccount/updateField/')?>'; 

    $wk_jq(qtyId).toggle(); 
    $wk_jq(editLink).hide(); 
    $wk_jq(updateButton).show(); 
    $wk_jq(resetButton).show(); 

    $qty = $wk_jq(qtyId).val(); 
    jQuery(valueId).html($qty); 
    hideReset(product_id); 

    var tmpQty = assignqty+parseInt($qty) ; 

    new Ajax.Request(url, { 
     method: 'post', 
     parameters: {id: product_id, qty: tmpQty}, 
     onComplete: function (transport) { 
     // alert(tmpQty); 
      jQuery(priceId).val($price);     
    jQuery(updatedqty).show().delay(2000).fadeOut(); 
      $updateButton.prop('disabled', false); 
     } 
    }); 
} 

你混合與正在使用的原型正常$變量您noconflict。例如$ qty,$ price和updatebutton。如果你想在這裏使用php變量,你必須將它們包裝在一個php標籤中並將它們回顯出來。

+0

你能請更新代碼包裝他們在一個PHP標籤,並呼應它。 – fresher

+0

哪些變量是php?因此,如果$價格是一個PHP可變 的jQuery(priceId).VAL(); –

+0

感謝您的支持...... – fresher

相關問題