Easy Edit Suite (1102) JavaScript plugin issue

Hello,


I've created an EES JavaScript plugin which includes a function that's called on the EasyEditBeforeLoad event.



Within the function, I call EasyEditAssetManager.getCurrentAsset(). However, in IE, on most occasions this function call fails, throwing these error messages:


    SCRIPT5007: Unable to get value of the property 'data': object is null or undefined
    SCRIPT5007: Unable to get value of the property 'indexOf': object is null or undefined

There's never an issue on Firefox or Chrome. I'm thinking that maybe IE mostly hasn't got around to initialising everything so that it's too early to call EasyEditAssetManager.getCurrentAsset() on EasyEditBeforeLoad; calling on EasyEditAfterLoad never causes an issue.



I need to make the call before the page loads so I can make amendments to objects for assets with, e.g., certain Metadata Schema attached.



I've not been able to get my head around the code. Is there any way of checking an object, for example, to see whether EasyEditAssetManager.getCurrentAsset() can be run successfully?



Many thanks,



Jamie

Hi Jamie,


That event you are binding to runs before almost everything in the EES, the function you are try to call requires objects that are instantiated as the code executes. Using the EasyEditBeforeLoad would be ideal for modifying objects prior to being instantiated. I'd be careful modifying core objects as well, they can change a bit between upgrades and if you can achieve the same result another way you might reduce the amount of work you have to do when you upgrade Matrix/EES.



If you were to go ahead and add extra stuff to the EasyEditAsset object could you perhaps just add it to the objects prototype?



Cheers,

Anthony

Hi Anthony - thanks, will make sure I amend the object prototype when adding new stuff. I guess I'm calling EasyEditAssetManager.getCurrentAsset() when, occasionally in IE, it's not yet been instantiated. To alternatively achieve what I'm after I could query on EasyEditAfterLoad and make amendments to the DOM on the fly.


Cheers,



Jamie


That sounds like a better idea, this event is triggered after all elements of the interface have loaded. One of the first batch API calls made is to retrieve the current asset information which takes time to fetch from the server and explains why there is no information available when you call getCurrentAsset()