getAttribute() inside an attachedListener function() returns 'null' (CKEditor 4.4.8) -


in plugin insert input elements of type "button". give elements data attributes. testing purposes called "data-test". further on attach listener recommended in answer. when click button function() called. inside function() need retrieve "data-test" attribute further actions.

but getattribute('data-test') returns null. guess variable "linkelement" not hold customer attributes.

any hints how reference data attributes correctly ?

....

var buttonelement = '<input  type="button"  value="click me"  data-test="test attribute"></input>'; var linkelement = ckeditor.dom.element.createfromhtml(buttonelement, editor.document); editor.insertelement(linkelement);  // attach listener capture clicks editor.editable().attachlistener( linkelement, 'click', function() {                             var attribute = linkelement.getattribute('data-test');                             ...                             console.log('attribute = ',attribute);                 } .... 

i answer question myself because problem solved. or better dissapeared. neither can coming nor why gone. bit weird may has been coding problem somewhere in long chain of neverending javascripts. anyway while days ago custom attributes not retrievable, now. code above works perfect. tested firefox, chrome , safari on mac. latest version.


Comments

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -