2016-12-29 172 views
0

asp.net項目的母版頁使用jQuery 1.10.2和jquery-ui 1.10.1。 我想要使用jquery 1.12.4和jquery 1.12.1來使用'checkboxradio'功能。在母版頁中使用較新版本的jquery ui以及舊版本

我現在有這個,從http://www.ipreferjim.com/2011/06/loading-newer-versions-of-jquery-and-jquery-ui-noconflict/發現,但它似乎仍然沒有恢復正常時,我得到

Uncaught Error: No label found for checkboxradio widget...

在頭(也試過這種體內後)

<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css"> 
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js" type="text/javascript"></script> 
    <script type="text/javascript"> 
     var $jQuery = jQuery.noConflict(true); 
     jQuery = $jQuery; // forces the new jQuery into global 

     jQuery(function ($) { 
      $.getScript('https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js', function() { 
       $("input[type='checkbox']").checkboxradio(); 
      }); 
     }); 
    </script> 

在身體

<label for="checkbox-nested-1">Heavy Metal<input type="checkbox" name="checkbox-nested-1" id="checkbox1"></label> 
<label for="checkbox-nested-1">Rap<input type="checkbox" name="checkbox-nested-1" id="checkbox2"></label> 
<label for="checkbox-nested-1">Pop<input type="checkbox" name="checkbox-nested-1" id="checkbox3"></label> 

感謝您的幫助!

+0

嘗試改變「的」屬性使用id屬性代替name屬性。 – Bindrid

+0

似乎沒有幫助。即使用jqueryui.com中的樣本替換了我的複選框,也沒有用。 –

回答

1

enter image description here

它開始,只要我把它改爲使用id作爲我的評論中提到爲我工作。

 <!DOCTYPE html> 
     <html> 
      <head> 

       <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css"> 
       <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js" type="text/javascript"></script> 
       <script type="text/javascript"> 
      var $jQuery = jQuery.noConflict(true); 
      jQuery = $jQuery; // forces the new jQuery into global 

      jQuery(function ($) { 
       $.getScript('https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js', function() { 
        $("input[type='checkbox']").checkboxradio(); 
       }); 
      }); 
       </script> 
      </head> 
      <body> 
       <label for="checkbox1">Heavy Metal<input type="checkbox" name="checkbox-nested-1" id="checkbox1"></label> 
       <label for="checkbox2">Rap<input type="checkbox" name="checkbox-nested-1" id="checkbox2"></label> 
       <label for="checkbox3">Pop<input type="checkbox" name="checkbox-nested-1" id="checkbox3"></label> 
      </body> 
     </html> 
相關問題