Scratchpad

dsp edited this page Jul 2, 2011 · 5 revisions
($.ajax 'foo/bar/baz' {} #(cb))

(underscore.map [a b c] foo)

(($ '.videos').fadeOut fast #(%.remove))

foo.bar()
(foo.bar)
(.bar foo)

foo.bar(1)
(foo.bar 1)
(.bar foo 1)

foo.say('nom').jump(10, 20).kill()
(.kill (.jump (.kill foo) 10 20))
(.kill (.jump (foo.kill) 10 20))
(-> foo
    (.say 'nom')
    (.jump 10 20)
    .kill)
(chain foo
       (.say 'nom')
       (.jump 10 20)
       .kill)
(chain (foo.say 'nom')
       (.jump 10 20)
       .kill)
(.. foo (say 'nom') (jump 10 20) (kill))

$('.hideable').click(function(e) {
    $(this).fadeOut('fast');
});
(.click ($ 'hideable') (fn [e] (.fadeOut ($ this) 'fast')))
(. ($ 'hideable') click (fn [e] (. ($ this) fadeOut 'fast')))
(chain ($ 'hideable')
       (.click (fn [e]
                 (. ($ this) fadeOut 'fast'))))
(($ 'hideable').click (fn [e]
  (($ this).fadeOut 'fast')))
(($ 'hideable').click
  #(($ this).fadeOut 'fast'))

(($ 'foo').(get actions cur_action))
(.(get actions cur_action) ($ 'foo'))