KineticJS: listening on .on ()

With KineticJS, is it possible to associate a function only once? As with jQuery equivalent ...

eg. in jQuery

// bad
$('.wrap a').on('click', myHandler);
// good
$('.wrap').on('click', 'a', myHandler);

I would like to do this with KineticJS, as there will be many objects there.

+5
source share
2 answers

This is Eric from KineticJS. Currently, you can use container.get () to get an array of nodes similar to jQuery, for example:

layer.get('Rect'); // returns all rectangles inside of layer
layer.get('.foo'); // returns all nodes with name foo inside layer
stage.get('#bar'); // returns node with id 'bar'

but you still cannot bind events to all nodes using a selector, for example:

layer.get ('Rect'). on ('click', ...);

I will add this to my task list, so it should probably be released in a couple of weeks :)

Hooray!

Eric

+5
source

, listner ( , ).

.

Fiddle: http://jsfiddle.net/9vsps/

, - , .

+1

All Articles