Make unregistered forward handlers fail silently (or with warning) but non-breaking
bernd-wechner opened this issue · 0 comments
bernd-wechner commented
Currently if you declare a forwarder with forward.JavaScript
the named handler must be registered on the client side with yl.registerForwardHandler
. If it is not then when the DAL widget is clicked it will display Searching....
and never complete, but on the console will appear this error:
22:04:42.777 autocomplete_light.js:465 Uncaught TypeError: handler is not a function
at Object.<anonymous> (autocomplete_light.js:465)
at Function.each (jquery.js:381)
at Object.yl.getForwards (autocomplete_light.js:438)
at jQuery.fn.init.data (select2.js:60)
at AjaxAdapter.query (select2.full.js:3620)
at Select2.<anonymous> (select2.full.js:5669)
at Select2.Observable.invoke (select2.full.js:655)
at Select2.Observable.trigger (select2.full.js:645)
at Select2.trigger (select2.full.js:5827)
at Select2.open (select2.full.js:5851)
at Select2.toggleDropdown (select2.full.js:5838)
at DecoratedClass.<anonymous> (select2.full.js:5609)
at DecoratedClass.Observable.invoke (select2.full.js:655)
at DecoratedClass.Observable.trigger (select2.full.js:645)
at HTMLSpanElement.<anonymous> (select2.full.js:1629)
at HTMLSpanElement.dispatch (jquery.js:5429)
at HTMLSpanElement.elemData.handle (jquery.js:5233)
(anonymous) @ autocomplete_light.js:465
each @ jquery.js:381
yl.getForwards @ autocomplete_light.js:438
data @ select2.js:60
AjaxAdapter.query @ select2.full.js:3620
(anonymous) @ select2.full.js:5669
Observable.invoke @ select2.full.js:655
Observable.trigger @ select2.full.js:645
Select2.trigger @ select2.full.js:5827
Select2.open @ select2.full.js:5851
Select2.toggleDropdown @ select2.full.js:5838
(anonymous) @ select2.full.js:5609
Observable.invoke @ select2.full.js:655
Observable.trigger @ select2.full.js:645
(anonymous) @ select2.full.js:1629
dispatch @ jquery.js:5429
elemData.handle @ jquery.js:5233
This should at worse issue a console warning and still function simply not calling (the unregistered) forward handler.
This makes for more robust application (the application I had in mind was to declare a handler by default on all my model forms, and only avail myself of it in JS on those I wanted to. But now I need the smarts both client and server side as to which fields will have a forwarder attached or not.