How can I add an onClick listener to a fileButton in CKEditor?

I'm working in the image uploader plugin, and have a button definition like this:

{ type : 'fileButton', id : 'uploadButton', filebrowser : 'info:txtUrl', label : editor.lang.image.btnUpload, 'for' : [ 'Upload', 'upload' ], onClick : function() {alert('hey')} }

I have tried defining the function to be called elsewhere as a named function, with no luck. I also haven't been able to add an onClick listener to other elements, but the buttonDefinition class here specifically says you should be able to add one to a button.


Have you tried:

document.getElementById('uploadButton').onclick = function() { alert('Hey!'); }


This is the class of FileButton in javascript

function FileButton(){ this.type = 'fileButton'; this.id ='uploadButton'; this.filebrowser = 'info:txtUrl'; this.label = "editor.lang.image.btnUpload"; this.forr = [ 'Upload', 'upload' ]; } FileButton.prototype.onClick = function() {alert('hey')}

Or if you have json object and want to wrap into javascript class object, define FileButton class and use jquery:

function FileButton(){ this.type = 'fileButton'; this.id ='uploadButton'; this.filebrowser = 'info:txtUrl'; this.label = "editor.lang.image.btnUpload"; this.forr = [ 'Upload', 'upload' ]; } FileButton.prototype.onClick = function() {alert('hey')}; var a = $.extend(new FileButton(), { type : 'fileButton', id : 'uploadButton', filebrowser : 'info:txtUrl', label : "editor.lang.image.btnUpload", forr : [ 'Upload', 'upload' ], onClick : function() {alert('hey')} }); console.log(a); a.onClick();

JsFiddle.net link


  • Uploading a file to server automatically inside an update panel does not work the first time
  • How to prevent user from clicking button more than once?
  • Find Elements by data-bind [Findsby]
  • Asp.net FileUpload problem “Arithmetic operation resulted in an overflow.” ContentLength is always -
  • How do I embed a custom user-control in MS Word?
  • gulp.watch running same task multiple times when saving many files
  • How to read data from a text file if the file location is not known in c#?
  • View/Download Pdf Files in React - Router 4
  • Special chars in Amazon S3 keys?
  • CKeditor stripping font tags instead of converting to span
  • How can I add div content to a new page in jspdf?
  • Send data from edittext to listview
  • Command line installation of Code Signing certificates, .p12 files, and mobileprovisions
  • Jquery Mobile pageLoading() Method how does it work?
  • Upload file that is in the cpan database
  • What does “t” refer to in this SQL?
  • CERN ROOT exporting data to plain text
  • nodemcu custom firmware build problems
  • perl, mysql - fasting way to upload a csv file into mysql?
  • Simulate click Geckofx vb,net
  • Django simple Captcha “No module named fields” error
  • Display images in Django
  • Problem deserializing objects from cache on MyBatis 3/Java
  • azure media services - The request body is too large and exceeds the maximum permissible limit
  • Word Open XML Mail Merge
  • Why does access(2) check for real and not effective UID?
  • Read a local file using javascript
  • Display issues when we change from one jquery mobile page to another in firefox
  • Why winpcap requires both .lib and .dll to run?
  • Python - Map / Reduce - How do I read JSON specific field in using DISCO count words example
  • Hibernate gives error error as “Access to DialectResolutionInfo cannot be null when 'hibernate.
  • How to set the response of a form post action to a iframe source?
  • coudnt use logback because of log4j
  • Are Kotlin's Float, Int etc optimised to built-in types in the JVM? [duplicate]
  • unknown Exception android
  • Binding checkboxes to object values in AngularJs
  • failed to connect to specific WiFi in android programmatically
  • Net Present Value in Excel for Grouped Recurring CF
  • jQuery Masonry / Isotope and fluid images: Momentary overlap on window resize
  • How to load view controller without button in storyboard?