AngularJS - jQuery - ui-sortable g.sortable不是函数

os8fio9y  于 2023-10-15  发布在  Angular
关注(0)|答案(3)|浏览(121)

我创建了一个表与拖动行的帮助下ui-sortable

<tbody ui-sortable="sortableOptions" ng-model="model.list">
   <tr ng-repeat="item in model.list">
      <td>
          <div class="form-group">
              <input type="text" class="form-control test-input" ng-model="item.Country" ng-readonly="!isEditable">
          </div>
      </td>
      <td>
          <div class="form-group">
              <input type="text" class="form-control test-input" ng-model="item.Value" ng-readonly="!isEditable">
          </div>
      </td>
   </tr>

这是控制器中的代码。

$scope.sortableOptions = {
            update: function(e, ui) {

                console.log(model.list);
            },
            stop: function(e, ui) {

                console.log(model.list);
            }
        };

我使用了require.js,并在那里添加了依赖项ui.sortable
每当我打开这个表格的页面时,我都会得到这个错误-
angular.js:12520 TypeError: g.sortable is not a function at w (http://localhost:90/bower_components/angular-ui-sortable/sortable.min.js:8:4649) at x (http://localhost:90/bower_components/angular-ui-sortable/sortable.min.js:8:4721) at link (http://localhost:90/bower_components/angular-ui-sortable/sortable.min.js:8:5003) at http://localhost:90/bower_components/angular/angular.js:8835:44 at invokeLinkFn (http://localhost:90/bower_components/angular/angular.js:8841:9) at nodeLinkFn (http://localhost:90/bower_components/angular/angular.js:8335:11) at compositeLinkFn (http://localhost:90/bower_components/angular/angular.js:7731:13) at nodeLinkFn (http://localhost:90/bower_components/angular/angular.js:8330:24) at compositeLinkFn (http://localhost:90/bower_components/angular/angular.js:7731:13) at compositeLinkFn (http://localhost:90/bower_components/angular/angular.js:7734:13) <tbody ui-sortable="sortableOptions" ng-model="model.list" class="ng-pristine ng-untouched ng-valid ng-isolate-scope">
你能帮帮我吗Thanks in advance

e5nqia27

e5nqia271#

ui-sortable依赖于jQuery,jQuery UI 1.9+。检查你是否在ui-sortable js文件之前有这些依赖项,然后你应该在正确的模块angular.module('myapp', ['ui.sortable']);中注入ui.sortable

eqqqjvef

eqqqjvef2#

任何人谁是面临同样的问题,但似乎有一切正确的喜欢;

1. jQuery is loaded.
2. angular-ui-sortable is being loaded correctly.
3. You've injected its dependency. 
   angular.module('myapp', ['ui.sortable']);
4. The code appears to be correct in the view

确保你已经在jquery之后和sortable之前包含了jquery-ui js文件。我也遇到了同样的问题,经过一段时间的头痛之后,我找到了这个解决方案here in this thread

4xrmg8kj

4xrmg8kj3#

UI.Sortable指令要求

AngularJS v1.2+
JQuery v3.1+
JQueryUI v1.12+
如果使用jQuery v1.x和v2.x,则添加UI.Sortable v0.14.x版本

相关问题