• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Manipulate Attachment Uploader



Is it possible to overwrite JS OOP just like PHP OOP?

I want to add an extrabutton to the form and overwrite XenForo.AttachmentInserter = function($trigger) without creating a own editor.js file (copy the complete attachment_editor.js file and change some lines)
If i would copy it, i also wouldn't be allowed to release the add-on because of the copyright problems^^


Active member
I don't know if this is the XenForo way to do it, but you might try this in the time being and see if it works:
_oldMethod = XenForo.someMethod;
XenForo.someMethod = function(param1, param2)
    _oldMethod.apply(this, arguments);
    // Add other things here
I think that should work if you only want to add something to the code. If you want to actually change something from the method you might try extending it like:
$.extend(XenForo.someMethod = function(param1, param2)
    // You would need to copy and paste the code of the original method here and change it to your liking


Well-known member
I don't think monkey patching is a good idea since XenForo is in active development and things get changed fast. Anyway, I have used quite some Javascript events designed in XenForo and it works really good. For instance, I once used AttachmentsChanged to modify the behavior of the uploader