0

なんらかの理由で、私が使用している Coffeescript コンパイラ (Rails 3.2.11 では以下の gem) がこれを翻訳しています。

$(".fancybox").each ->
  item_id = this.id
  $(this).dblclick ->
    $(this).fancybox
      href: "items/#{item_id}",
      type: 'ajax'

これに

  $(".fancybox").each(function() {
    var item_id;

    item_id = this.id;
    $(this).dblclick(function() {});
    return $(this).fancybox({
      href: "items/" + item_id,
      type: 'ajax'
    });
  });

その内側のdblclickブロックが次のようになる場合:

$(this).dblclick(function() {
  return $(this).fancybox({
    href: "items/" + item_id,
    type: 'ajax'
  });
});

これを防ぐにはどうすればよいですか、またはコンパイラに正しくフォーマットさせるために回避するにはどうすればよいですか?

使用する

  coffee-rails (3.2.2)
  coffee-script (2.2.0)
  coffee-script-source (1.6.2)
4

1 に答える 1