在母版页中使用较新版本的jquery ui以及旧版本
问题描述:
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>
感谢您的帮助!
答
它开始,只要我把它改为使用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>
尝试改变“的”属性使用id属性代替name属性。 – Bindrid
似乎没有帮助。即使用jqueryui.com中的样本替换了我的复选框,也没有用。 –