jQuery sortable不是函数 [英] jQuery sortable is not a function

查看:120
本文介绍了jQuery sortable不是函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Sortable jQuery UI插件版本1.8.16使可单击并拖曳的项目的有序列表.但是,我不断收到错误$("#ol-id ol").sortable is not a function,其中'ol-id'是列表的ID.我的代码如下:

I am trying to make an ordered list of items click-and-draggable with the Sortable jQuery UI plugin version 1.8.16. However, I keep getting the error that $("#ol-id ol").sortable is not a function, with 'ol-id' being the id of the list. My code is as follows:

//Sorting stuff
if($("#li-id li").size()>1) {
    $("#ol-id ol").sortable({
        revert:         true,
        axis:           'y',
        containment:    'parent',
        cursor:         'move',
        handle:         'div.link_div',
        smooth:         false,
        opacity:        0.7,
        tolerance:      'pointer',
        start: function(){
            $("#ol-id").removeClass("bottom_dragged");
        },
        update: function(){
            $("#ol-id ol").sortable({disabled : true});
            $("#saving_indicator").html("saving...")
            $("#saving_indicator").show();
                            //do other stuff...
        }
    })
}

奇怪的是,该错误在Firebug中显示为与update: function(){一致.

Oddly, the error shows up in Firebug as being on the line with update: function(){.

我已验证在加载页面和jQuery UI库之后都调用了此函数.我在标头中同时包含了jquery-1.6.2.min.js和jquery-ui-1.8.16.custom.min.js.而且,我已经验证了所有id名称都是正确的,并且匹配它们的HTML对应名称.

I have verified that this function is called after both the page is loaded and the jQuery UI library is loaded. I am including both jquery-1.6.2.min.js and jquery-ui-1.8.16.custom.min.js in the header. Moreover, I have verified that all id names are correct and match their HTML counterparts.

因此,如果不是缺少与资源相关的内容,是什么原因引起的?

So if it's not this missing resource-related stuff, what is causing the problem?

这是我的HTML标头:

here is my HTML header:

<link href="/_css/styles.css?mod=1317745564" type="text/css" rel="stylesheet">
<link href="/_javascript/qtip/jquery.qtip.min.css?mod=1315947301" type="text/css" rel="stylesheet">
<script type="text/javascript" async="" src="http://www.google-analytics.com/ga.js">
<script type="text/javascript" async="" src="http://www.google-analytics.com/ga.js">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js" type="text/javascript">
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js">
<link rel="stylesheet" type="text/css" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/themes/start/jquery-ui.css">
<link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/themes/le-frog/jquery-ui.css">
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.js" type="text/javascript">
<script src="/_javascript/sets.js?mod=1320080042" type="text/javascript"> //Sorting stuff code is here
<script type="text/javascript" src="http://dev.selfcheck.vudat.msu.edu/_javascript/jquery.jsonp.js">
<script type="text/javascript" src="http://dev.selfcheck.vudat.msu.edu/_javascript/jquery.form.js">
<script type="text/javascript" src="http://dev.selfcheck.vudat.msu.edu/_javascript/qtip/jquery.qtip.min.js">
<link href="/_css/ui/ui.core.css?mod=1315947279" type="text/css" rel="stylesheet">
<link href="/_css/ui/ui.theme.css?mod=1315947280" type="text/css" rel="stylesheet">

推荐答案

jQuery UI和jQuery必须以特定顺序加载:

jQuery UI and jQuery must be loaded in a certain order:

<script src="jquery.js">...
<script src="jquery-ui.js">...

确保在jQuery之后包含jQuery UI.

Make sure you are including jQuery UI after jQuery.

这篇关于jQuery sortable不是函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆