Вопрос

When mousing into a .thumb element I'd like to change #full-image's src to the .thumb element's src. What I have that is not working:

(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)))))

Can anyone point me to where I can use this? Enfocus is built on domina which is built on closure libs which is built on plain js. I don't know which layer I should be looking for this or if that is even the idiomatic solution.

Это было полезно?

Решение

I got it working with .-currentTarget. See http://ckirkendall.github.io/enfocus-site/#doc-events and http://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)))))
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top