<script src="../../../js/jquery-1.3.2.min.js" type="text/javascript"></script>
<!--上传图片只能搭载1.3.2.min.js 版本-->
<script src="../../../js/jquery.form.js" type="text/javascript"></script>
<!--autocomplete下拉搜索开始-->
<link href="../../../js/jquery-ui-1.12.1.custom/jquery-ui.min.css" rel="stylesheet" type="text/css" />
<!--autocomplete需要高版本js,不要修改它的顺序,因为autocomplete必须-->
<script src="../../../js/jquery-1.8.0.js" type="text/javascript"></script>
<script type="text/javascript">
var $jq_1_8_0 = jQuery.noConflict(); //将jQuery还原为上一个被覆盖的版本
</script>
<script src="../../../js/jquery-ui-1.12.1.custom/jquery-ui.js" type="text/javascript"></script>
<script src="../../../js/myClass.js" type="text/javascript"></script>
//下面是myClass.js代码的写法。
(function ($) {
var classData = null;
//var testSource = ["abc","abd","abc1","bcd","bcdf","def","2016","2015","2017","2018"];
window.onload = function () {
classData = loadClassData();
// alert($.fn.jquery);
$("#AddClass").autocomplete({
minChars: 0, //输入多少字符触发
minLength: 0,
source: classData,
mustMatch: true,
focus: function (event, ui) {
$("#AddClass").val(ui.item.label);
$("#HiddenField_Class").val(ui.item.value);
return false;
},
select: function (event, ui) {
$("#AddClass").val(ui.item.label);
$("#HiddenField_Class").val(ui.item.value);
return false;
}
}).autocomplete("instance")._renderItem = function (ul, item) {
return $("<li>")
.append("<div>" + item.label + "</div>")
.appendTo(ul);
};
};
//下拉类别
function loadClassData() {
var arrData = [];
var classItem = function classItemObj(value, text) {
this.value = value;
this.label = text;
}
$.ajax({
type: "get",
async: false,
url: "/Manager/AjaxRequest/SelectClass.ashx?ParentId=20150424163224980114&cmd=ps",
success: function (data) {
var dataObj = eval("(" + data + ")"); //转换为json对象
$.each(dataObj.Table, function (i, item) {
// var html = "<option value='" + item.class_aid + "'>" + item.class_name + "</option>";
arrData.push(new classItem(item.class_aid, item.class_name));
})
}
});
return arrData;
}
})($jq_1_8_0);
主要代码一个是在,还原到上一个版本$问题,一个是将特定版本jquery传入自动用函数问题。