這是我的代碼。jquery droppable error
$("#selected").droppable({
drop: function() {
total = total + 1;
alert('total : ' + total);
}
});
我收到以下錯誤:
$( 「#選擇」)可放開不是一個函數。
這應該是什麼解決方案?
這是我的代碼。jquery droppable error
$("#selected").droppable({
drop: function() {
total = total + 1;
alert('total : ' + total);
}
});
我收到以下錯誤:
$( 「#選擇」)可放開不是一個函數。
這應該是什麼解決方案?
您可能遇到以下問題之一尊重你的<script>
標籤:
jQuery
對象)第三個是一種很常見的被忽視的問題,其中所有的jQuery UI添加的插件得到另一個jQuery的交口稱讚包括覆蓋jQuery
對象。
只是一對夫婦的標準檢查下列事項:
1)你有沒有包括的jquery.js這個腳本之前& jqueryui.js?
2)在這行之前是否有語法錯誤?
3)你是否在$(document).ready(...)或同等內容(不一定是問題,但以防萬一)內執行此操作
以防萬一有人仍然需要這個:你可能已經說明了上述所有內容,但仍然無效。如您所知,現在您可以下載jquery ui的自定義版本。
檢查您的是否有可拖動組件。如果不確定,請嘗試從http://jqueryui.com/download下載並確保也檢查組件可放置。
(這是我的情況)
在Angular爲我工作之前添加JQuery腳本。 Dragdrop文檔缺少這條信息。
我的index.html弄成這個樣子:
<script src="bower_components/jquery/dist/jquery.js"></script>
<script src="bower_components/jquery-ui/jquery-ui.js"></script>
<script src="bower_components/angular/angular.js"></script>
搜索者的利益(以下關於角@Paulo佩德羅索的答案)。
在鏈接函數中使用元素時,可以通過AngularJS指令看到此錯誤。
對我來說問題在於元素是通過jqLite元素而不是JQuery來實現的。必須將其轉換爲JQuery才能訪問JQuery UI函數。即
myApp.directive('jqDrop', ['$rootScope', function ($rootScope) {
return {
restrict: 'A',
link: function (scope, elm, attr) {
// NOTE: elm comes in under jqLite, so need to jQuery it.
$(elm).droppable({
drop: function (event, ui, x) {
// Do stuff here...
},
greedy: false,
over: function (event, ui) {
},
});
}
};
}]);
沒得做另一個應用這種轉換(但不知道爲什麼),所以在這裏發帖救別人了一下調查的。