Вопрос

I'm trying to get modifer key data from an event with jayq (see here).

This works just fine

(delegate $body note-list-item :click
      (fn [e]
        (.preventDefault e)
        (js/alert "clicked!")))

But this doesn't.

(delegate $body note-list-item :click
      (fn [e]
        (.preventDefault e)
        (if (.metaKey e)
          (js/alert "meta clicked")
          (js/alert "no meta"))))

The Javascript console in Chrome gives me Uncaught TypeError: Property 'metaKey' of object #<Object> is not a function

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

Решение

And then I immediately figured it out, of course. metaKey is a property of the object, not a method. In Clojurescript you get it with (.-metaKey e) (note the dash). See here for more details.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top