Enfocus交换img src到$(this).attr('src')

时间:2014-05-07 00:40:26

标签: clojurescript

当鼠标移入.thumb元素时,我想将#full-image src更改为.thumb元素{{{} 1}}。我所拥有的不起作用:

src

有人能指出我可以使用(defaction change-src [selector src] [selector] (ef/set-attr :src src)) (defaction thumb-hover [] [".thumb"] (events/listen :mouseenter #(change-src "#full-image" ; Looks like the following needs to be replaced ; with some $(this).attr('src') equivalent. (ef/from % (ef/get-attr :src))))) 的地方吗? this构建于Enfocus之上,domina基于closure libs构建,它基于普通js构建。我不知道我应该寻找哪一层this,或者这是否是惯用的解决方案。

1 个答案:

答案 0 :(得分:1)

我让它与.-currentTarget合作。请参阅http://ckirkendall.github.io/enfocus-site/#doc-eventshttp://docs.closure-library.googlecode.com/git/class_goog_events_Event.html

(defaction change-src [selector src]
  [selector] (ef/set-attr :src src))

(defaction thumb-hover []
  [".thumb"] (events/listen :mouseenter
                     #(change-src "#full-image"
                                  (ef/from (.-currentTarget %)
                                           (ef/get-attr :src)))))