2

I'm converting a Dojo 1.6.1 DataGrid example to use the AMD loader in Dojo 1.7, and try and do things the "1.7 way".

Currently, I have dojo.connect(grid, "onApplyEdit", applyEdit); but I'd like to convert this to use dojo/on.

I thought a simple conversion to on(grid, "onApplyEdit", applyEdit); might work, but it does not.

I've noticed for some of the on() examples, the event names are regular dom events, like click.

Have the event names for the grid changed, or is dojo/on just not ready to handle non-DOM events, or perhaps the DataGrid has not been updated to emit on() events?

Reuben
  • 4,136
  • 2
  • 48
  • 57

2 Answers2

3

dojo.on works with DOM- and browser-related events. Non-DOM and non-browser events are simple method calls. You can connect to them using AOP. See dojo/aspect.js for more details: http://livedocs.dojotoolkit.org/dojo/aspect

Eugene Lazutkin
  • 43,776
  • 8
  • 49
  • 56
  • In the case of above example, would I be using aspect.after(grid, "doApplyEdit", applyEdit), since that is the "do" method that appears on the grid? – Reuben Jan 03 '12 at 12:17
  • 1
    Yeah, why not. Because pseudo events usually do not have a body, you can use any AOP method you like. If you want chain handlers in FIFO fashion, like `dojo.connect` does, "after" is your ticket. – Eugene Lazutkin Jan 04 '12 at 06:01
0

Well I got it working this way:

var signal = dojo.on( grid4, 'ApplyCellEdit', function(inValue, inRowNdx, inStoreNdx){..});

Leave out the 'on' from the eventname 'onApplyCellEdit'.

arjan
  • 1
  • 1