Opened 5 years ago

Closed 5 years ago

#13092 closed Bug (invalid)

getAttribute() inside an attachedListener function() returns 'null'

Reported by: Heinz Owned by:
Priority: Normal Milestone:
Component: General Version:
Keywords: Cc:

Description

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 to capture clicks
editor.editable().attachListener( linkElement, 'click', function() {
                            var attribute = linkElement.getAttribute('data-test');
                            ...
                            console.log('attribute = ',attribute);
                }

In the plugin code sample above a listener is attached (as recommended by Reinmar) to an 'input' element to capture mouseclicks. To transport data a customer attribute is implemented. While the anonymos function is called perfectly, the 'attribute = linkElement.getAttribute('data-test');' returns 'null'.

Change History (3)

comment:1 Changed 5 years ago by Piotrek Koszuliński

Status: newpending
Version: 4.4.8 (GitHub - master)

For me it logs:

attribute =  test attribute

So everything works perfectly fine.

I tested on Chrome using the replacebycode.html sample.

Could you provide more details on how to reproduce this issue? Perhaps a working sample.

comment:2 Changed 5 years ago by Heinz

For any reason it works for me now too. Something in my scripts must have been changed and removes this 'bug'. Days ago it wasn'nt working. The click handler was called but the returned attributes where empty, weird. I test with Safari, FireFox and Chrome, all latest versions. Ok, so this ticket can be closed. Thanks a lot … 

comment:3 Changed 5 years ago by Piotrek Koszuliński

Resolution: invalid
Status: pendingclosed

Cool :) Closing tickets is always pleasure.

Note: See TracTickets for help on using tickets.
© 2003 – 2019 CKSource – Frederico Knabben. All rights reserved. | Terms of use | Privacy policy