question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Editor.getSelected() giving me undefined.

See original GitHub issue

Hi @artf I want to append dynamic pages to the specific link trait. Here is what i am using. const component = editor.getSelected(); component.getTrait('link').set('options', [ { value: 'opt1', name: 'New option 1'}, { value: 'opt2', name: 'New option 2'}, ]); This is giving component is undefined in the console because by default not any element is selected Could you please guide me on this . I want to append that pages in list of link trait whenever i click on the link

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Abhisheknanda1344463commented, Sep 6, 2020

Thank you so much @Ju99ernaut Now,It working perfectly. Really appreciate your help. Closing this issue.

1reaction
Ju99ernautcommented, Sep 5, 2020

You can check if component.getTrait('href') gets anything first:

editor.on('component:selected', component => {
   component.getTrait('href') && component.getTrait('href').set('options', data.list);
});
Read more comments on GitHub >

github_iconTop Results From Across the Web

In CKEditor getSelection() returns null value in IE
So i checked the code and found that getSelection() having an null value. Please help me how to solve it. I tried some...
Read more >
Uncaught TypeError: Cannot use 'in' operator to search for ' ...
Hi, I am seeing error with Kendo Editor : Uncaught TypeError: Cannot use 'in' operator to search for 'getSelection' in undefined.
Read more >
7561 (IE 'editor.getSelection()' is null or not an object)
According to the documentation, and my observations, editor.getSelection() can return null. This statement should be wrapped in a conditional block to avoid ...
Read more >
Unable to get property 'createrange' of undefined or null ...
var range = editor.get_document().getSelection().createRange(); but unfortunatly it is not working. JavaScript.
Read more >
Unable to get property 'createRange' of undefined or null ...
selection, but with IE11 it changed to Document.getSelection(). That's the bad news. The good news is that form.js gets this docEditor by ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found