To Script Editors: Changes to Events Mechanism in Scripts
Hi all,
I know that many script editors are struggling with getting their scripts updated to work in the latest version of the WME.
Looking at the debug console in Chrome, many of the scripts all suffer from the same problem, which is that Waze changed the way they handle events. So, if you have a hook in your code to execute your function when things change, save, load, etc, it's probably broken. Usually this is done by calling the "register" or "registerPriority" method of the events collection.
For example:
W.model.venues.events.register
W.model.mapUpdateRequests.events.register
...
If you have this type of call in your code, you will have to use the new "on" syntax to make this hook.
Old Code
New Code
It's a simple change that should fix a lot of script issues out there.
Also, the new WME renamed or reclassed lots of objects (as usual). You'll just have to use the new names to refer to your objects. Here is an example for the code to actually click the save button from your code:
Old Code
New Code
I'm really not good at coding new things, but I'm very strong in reading/hacking/optimizing other people's code. If any of you need help in debugging your scripts, I'll be glad to offer my assistance, please feel free to send me a PM.
Cardyin
I know that many script editors are struggling with getting their scripts updated to work in the latest version of the WME.
Looking at the debug console in Chrome, many of the scripts all suffer from the same problem, which is that Waze changed the way they handle events. So, if you have a hook in your code to execute your function when things change, save, load, etc, it's probably broken. Usually this is done by calling the "register" or "registerPriority" method of the events collection.
For example:
W.model.venues.events.register
W.model.mapUpdateRequests.events.register
...
If you have this type of call in your code, you will have to use the new "on" syntax to make this hook.
Old Code
Code: Select all
W.model.mapUpdateRequests.events.register("objectschanged", null, URComments.urcUREvent_onObjectsAdded('mapUpdateRequests objectschanged'));
Code: Select all
W.model.mapUpdateRequests.on("objectschanged", URComments.urcUREvent_onObjectsAdded('mapUpdateRequests objectschanged'));
Also, the new WME renamed or reclassed lots of objects (as usual). You'll just have to use the new names to refer to your objects. Here is an example for the code to actually click the save button from your code:
Old Code
Code: Select all
$('#toolbar #edit-buttons .WazeControlSave').trigger('click');
Code: Select all
$('.toolbar-button.waze-icon-save').trigger('click');
Cardyin