Closed pseudonom closed 10 years ago
It seems quite plausible to me that on ought to be defined like this.
on
foreign import on "function on(evt) { \ \ return function(act) { \ \ return function(ob) { \ \ return function() { \ \ return ob.on(evt, function() { \ \ act($(this))(); \ \ }); \ \ }; \ \ }; \ \ }; \ \}" :: forall eff a. String -> (J.JQuery -> Eff eff a) -> J.JQuery -> Eff (dom :: J.DOM | eff) J.JQuery
With the original definition, something like
J.select ".foo" >>= J.on "click" (J.appendText "bar")
will add "bar" to every "foo" element. The proposed definition allows both this behavior and clicked-element-specific behavior.
I think you're right. Feel free to submit a PR or I can just fix this. For consistency we should probably use jQuery instead of $ though.
It seems quite plausible to me that
on
ought to be defined like this.With the original definition, something like
will add "bar" to every "foo" element. The proposed definition allows both this behavior and clicked-element-specific behavior.