Event handlers in 2.2 vs v2.1

Being behind the times, I've just move one of my apps to enyo 2.2, and an event that was working in 2.1 dores not seem to work in 2.2

in my 2.1 code I have

enyo.kind({
	name: "FlotView",
	kind: "Control",
	handlers: {
		onplotclick: "myPlotClick"
	},
	myPlotClick: function(iS, iE) {
		enyo.log("myPlotClick");
		return true;
	},
});
The above code handles the event in 2.1 but not 2.2, what do I need to do, to make 2.2 catch the event?

Comments

  • As far as I remember, nothing changed from 2.1 to 2.2 in how handlers were hooked up. https://github.com/enyojs/enyo/wiki/Enyo-2.2-Release-Notes are the 2.2.0 release notes, but there's nothing there about event handlers changing.

    What kind of event is onplotclick? Something generated by another Enyo component?
  • onplotclick is generated by a trigger call within a jquery object.

    http://api.jquery.com/trigger/
  • Did you add code to your copy of 2.1 that called enyo.dispatcher.listen(document, "plotclick") to tell Enyo to listen for DOM events of this type? We can't register for any random DOM event; it has to be added to our listener system to be turned into an enyo event.
  • Bingo, thanks for that, me being very dumb. Need to make a note of that so I don't forget in the future
  • Hi, sorry for digging up an old thread like this, but I'm trying to do the exact same thing in Enyo 2.2 and I simply cannot get it to catch the "plotclick" event.

    this never gets triggered, but the listener is registered when I look for it in the debugger.
    enyo.dispatcher.listen(document, "plotclick", function() { enyo.log("enyotest"); });

    this works fine, but I don't want to use jQuery for this, as I would need to re-send the event to my enyo kind using enyo.Signals or enyo.master.waterfallDown.
    $(document).on("plotclick", function() { enyo.log("jquerytest"); });

    How did you get it working?
  • So, you are saying that if you add the
    debug enyo.dispatcher.listen()
    that it does display 'enyotest'?

    Did you do a
    dispatcher.listen(document, 'plotclick');
    in your non-debug version?
  • edited December 2015
    RoySutton:
    No, it doesn't display 'enyotest'.
    What I meant was that 'plotclick' is added to the list of document events, but it never gets triggered.

    theryanjduffy:
    enyo.dispatch does work, but I still need the data in the event and I cannot find it when I use enyo.dispatch.
    In your example, if you add this:
    $(document).on('plotclick', function(event,pos,item) { console.log(event); console.log(pos); console.log(item); });
    you will see that plotclick sends data in the 'pos' and 'item' parameters that doesn't seem to be available after enyo.dispatch.

    If you replace your handlePlotClick function with this:
    handlePlotClick: function (e,p,i) { this.log(e); this.log(p); this.log(i); },
    You will see that the data from 'pos' and 'item' in the JQuery event is nowhere to be found.

    Does enyo.dispatch ignore that data?

    edit:
    the 'solution' I'm currently using is this:
    $(document).on("plotclick", function(event, pos, item) { enyo.master.waterfallDown("plotclick", {event: event, pos: pos, item: item}); });
    not pretty.
  • You might try decorating the event that gets dispatched and handle it accordingly: http://jsfiddle.net/USpFK/98/
  • That works, didn't think about that. Thanks.
    It is basically what I already did with enyo.master.waterfallDown though. ;)

    Still, I would prefer to get rid of the jQuery event catcher.
Sign In or Register to comment.