http://d.hatena.ne.jp/nantekkotai/20110909/1315582529のようにコンパイルオプションで対応するのでもいいのですが、 Railsやmiddlemanなど、自動でコンパイルするのでコンパイルオプションを与えられない時のために。 クラス定義をしているファイルの最後に window.ClassName = ClassNameと書いてあげると、ClassName クラスはグローバルになるので、どこでも使えます。
// Generated by CoffeeScript 1.3.3 (function() { this.GlobalClass = (function() { function GlobalClass() {} return GlobalClass; })(); }).call(this); Register as a new user and use Qiita more conveniently You get articles that match your needsYou can efficiently read back useful informationYou can use dark themeWhat you can do with signing up
Someone know how can I use this option in Rails 3.1? Now CoffeScript puts a function with .call(this) on each file, but I want to remove this. EDIT: "Can't find variable” error with Rails 3.1 and Coffeescript" and "Pattern for CoffeeScript modules" have what I want. I'll change my global vars to use @global scope.
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く