Allow registration of multiple JS handlers to a single element

pkp
ojs3

#1

Hi there,

i need to register an additional handler to element #submitStep1Form via a plugin that has already a handler registered to it.

Currently when i call $('#submitStep1Form').pkpHandler('... the console spits out the exception The handler ... has already been bound to the selected element. This is caused by Handler.js because it allows only one handler binding, see https://github.com/pkp/pkp-lib/blob/master/js/classes/Handler.js#L82.

I reworked the code by simply storing the handler bindings via an array in data('pkp.handlers') and rewriting all code parts based on the data stored basically by iterating over the array. This seems to work without breaking existing functionality.

Would this be a change you are willing to include in the GitHub repo?

So lonG


#2

Hi @j1shin,

I’d be willing to review a pull request – but more broadly we’re gradually replacing those Javascript structures with new ones based on vue.js (as you’ll see e.g. in the reviewer selection area). Accordingly we’re avoiding much investment in time on the older-style handlers.

Regards,
Alec Smecher
Public Knowledge Project Team


#3

Hi @asmecher, nevermind, i had the idea to just bind the handler to another element … and it works. So no need to rewrite core code. Feature request can be closed / deleted.


#4

Hi @j1shin,

Glad to hear it!

Thanks,
Alec Smecher
Public Knowledge Project Team