对象不支持属性或方法'selectbox' [英] Object doesn't support property or method 'selectbox'
问题描述
我使用的是 http:// www。 bulgaria-web-developers.com/projects/javascript/selectbox/ 。
我还有一个js文件中的链接,其中包含以下代码:
I also have a linked in js file, which contains the following code:
function loadTeams() {
var responseArray, optionsOutput = '';
$.ajax({
type: "GET",
url: "/ajax/team",
dataType: "json",
success: function (response) {
responseArray = response.array;
for (var i = 0; i < responseArray.length; i++) {
optionsOutput += '<option value="' + responseArray[i] + '">' + responseArray[i] + '</option>';
}
$("#teamSelect").find('option')
.remove()
.end()
.append(optionsOutput);
$("#teamSelect").selectbox({ speed: 100 });
},
error: function (xhr, ajaxOptions, thrownError) {
$("#teamSelect").find('option')
.remove()
.end()
.append('<option value=""></option>');
}
});
}
IE浏览器。在那里,我得到:
This works fine in all browsers except IE. In there, I get:
SCRIPT438:对象不支持属性或方法'selectbox'
globals.js,line 38个字符4
SCRIPT438: Object doesn't support property or method 'selectbox' globals.js, line 38 character 4
相当于以下行:
$("#teamSelect").selectbox({ speed: 100 });
我已经尝试过将这些戏剧性和丑陋的方法,将整个jQuery插件js文件复制到 globals.js
,我仍然收到错误。
I've tried even such dramatic and ugly approaches as copying the entire jQuery plugin js file into globals.js
, and I still get the error.
什么给了?
编辑 - 更新:我尝试将 #teamSelect
分配给 var
并调用 var.selectbox
,但我收到相同的错误。
Edit - Update: I've tried assigning the #teamSelect
to a var
and calling var.selectbox
, but I'm getting the same error.
推荐答案
Aha,问题是jQuery的selectbox插件(可能是jQuery本身)和Foundation 4之间的冲突。当我整合了基础4 ,我按照他们的网站上的例子,把我复制并粘贴在这个隐秘的位中:
Aha, the problem was a conflict between jQuery's selectbox plugin (probably jQuery itself) and Foundation 4. When I integrated Foundation 4, I followed the example on their site which had me copy and paste in this cryptic bit:
<script>
document.write('<script src=' +
('__proto__' in {} ? '/js/vendor/zepto' : '/js/vendor/jquery') +
'.js><\/script>');
</script>
这是加载zepto或jquery,然后我从Google CDN加载jquery。删除此行并放置我的Google CDN jQuery首先解决了冲突。
This was loading zepto or jquery, and THEN I was loading jquery from the Google CDN. Removing this line and placing my Google CDN of jQuery first resolved the conflict.
这篇关于对象不支持属性或方法'selectbox'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!