Stop propogation of events

34 views
Skip to first unread message

acagle

unread,
Jul 25, 2012, 8:29:27 PM7/25/12
to c2-...@googlegroups.com
Is there a way to stop focus events from propagating when using C2, bind! and unify? I tried looking in the source for events.cljs, but it seems the only option is :capture. The following results in an endless loop of dialog boxes. 

(ns client.list
  (:use-macros [c2.util :only [p pp bind!]])
  (:use [c2.core :only [unify]])
  (:require
    [client.core :as core]
    [c2.dom :as dom]
    [c2.event :as event]
    [clojure.string :as  str]))
...
(event/on "h3" ".title" :blur
  (fn [d _ e]
    (let [msg "rpc.client.list/event/on h3 .title :blur"]
      (.log js/console msg)
      (js/alert msg)))
  :capture true)

Am I missing something that handles this case?

Thanks,
Anthony
btw:  other than this C2 is working pretty well even though I just started using it, very clear and concise

Kevin Lynagh

unread,
Jul 25, 2012, 8:44:34 PM7/25/12
to c2-...@googlegroups.com
This doesn't seem like an issue with bind! or unify.

There are three separate points here to clarify:

1) I'm not sure what the story is using (event/on "h3" ...) since you shouldn't have anything nested under an <h3> tag.

2) The `on` function actually has some special handling that assumes the container element (i.e., the first argument) is populated with children from a unify call, and thus have data attached to the nodes.
If you just want a plain ol' event listener, use `on-raw`.

3) Event capturing has nothing to do with stopping propagation. When an event happens on an element (e.g., you click it), the event starts at the DOM root and moves down into the triggering node in the "capture" phase. Once it reaches the triggering node, it starts going back out to the root in the "bubble" phase. Typically you nab events in the bubbling phase.

I can't see your DOM structure, but my guess about why you're getting a loop is because you're using `on` instead of `on-raw` and the internal helper logic is checking each of h3's parents for attached data.



--
You received this message because you are subscribed to the Google Groups "C2-cljs" group.
To unsubscribe from this group, send email to c2-cljs+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Kevin Lynagh
Keming Labs
http://keminglabs.com
888.502.1042

Reply all
Reply to author
Forward
0 new messages