咖啡脚本中jQuery($)的用途是什么?
我不熟悉jQuery和coffee脚本。在我的旅程中,我在咖啡剧本的开头几次碰到了以下结构:咖啡脚本中jQuery($)的用途是什么?,jquery,playframework,coffeescript,playframework-2.1,Jquery,Playframework,Coffeescript,Playframework 2.1,我不熟悉jQuery和coffee脚本。在我的旅程中,我在咖啡剧本的开头几次碰到了以下结构: jQuery ($) -> $table = $('.container table') productListUrl = $table.data('list') ... 将其转换为以下javascript (function() { jQuery(function($) { var $table, productListUrl; $table = $('.co
jQuery ($) ->
$table = $('.container table')
productListUrl = $table.data('list')
...
将其转换为以下javascript
(function() {
jQuery(function($) {
var $table, productListUrl;
$table = $('.container table');
productListUrl = $table.data('list');
return $.get(productListUrl, function(products) {
return $.each(products, function(index, eanCode) {
var row;
row = $('<tr/>').append($('<td/>').text(eanCode));
return $table.append(row);
});
});
});
}).call(this);
有人能帮点忙吗?正如您所说,jQueryfunction${…}是一种为DOM就绪事件声明回调的方法
回调函数的参数$确保此函数中的$符号是jQuery快捷方式,如中所述。我确信这是重复的,但我现在很难找到它。不管怎样,读一读,你就会知道外部函数是用来做什么的。
$(function() {
...
});