我创建了一个文件叫做:jquery.js:
$(document).ready(function{
jQuery('#sortable1, #sortable2')
.sortable(
{'connectWith':'.connectedSortable',
'dropOnEmpty':true,
'scroll':true,
items: "li:not(.emptyMessage)",
receive: function(event, ui) {
//hide empty message on receiver
$('li.emptyMessage', this).hide();
//show empty message on sender if applicable
if($('li:not(.emptyMessage)', ui.sender).length == 0){
$('li.emptyMessage', ui.sender).show();
} else {
$('li.emptyMessage', ui.sender).hide();
}
}
});
});
在我的index.html.erb
,我有:
我添加了第一个脚本 SRC ...:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js" type="text/javascript"></script>
<script src="assets/jquery.js" type="text/javascript"></script>
<ul id="sortable1" class="connectedSortable">
<li>List 1-1</li>
<li>List 1-2</li>
<li>List 1-3</li>
<li>List 1-4</li>
<li class="emptyMessage">This is empty</li>
</ul>
<ul id="sortable2" class="connectedSortable">
<li>List 2-1</li>
<li>List 2-2</li>
<li>List 2-3</li>
<li>List 2-4</li>
<li class="emptyMessage">This is empty</li>
</ul>
<div class="clear"></div>
在中console
,我得到了下一个错误:
Uncaught SyntaxError: Unexpected token { :3000/assets/jquery.js?body=1:1
Uncaught ReferenceError: jQuery is not defined jquery_ujs.js:429
Uncaught ReferenceError: jQuery is not defined jquery.purr.js:162
Uncaught ReferenceError: jQuery is not defined best_in_place.js:561
Uncaught ReferenceError: jQuery is not defined workers.js:3
Uncaught ReferenceError: $ is not defined application.js:19
Uncaught SyntaxError: Unexpected token {
我认为所有的错误都是因为 jquery.js。
请帮忙。