How to add toolbar handlers dynamically?
See original GitHub issueI have a service that has access to the quill editor. (quill
variable below)
co-links-module.ts
...
const toolbar = quill.getModule('toolbar');
if (toolbar) {
// toolbar.addHandler('quickadd', this.handleQuickadd.bind(this.quill)); // <==== This does not work
toolbar.addHandler('quickadd', (value) => { // <==== This does not work
this.handleQuickadd(value);
});
}
...
The code snippet runs without errors, however when I click on the custom toolbar button, nothing happens.
If I instead add that handler directly to the config:
editor.component.ts
...
toolbar: {
container: [
['bold', 'italic', 'underline', 'strike'], // toggled buttons
...
['quickadd'], // link and image and video
],
handlers: {
...
'quickadd': (value) => {
this.coLinksModule.handleQuickadd(value); // <==== This does work
},
},
},
And then click the button, it does work. I do not understand why. Not even after hours of trying to wrap my head around it.
I am wondering why I cannot add a handler outside of the config? Any ideas what is going on?
Issue Analytics
- State:
- Created 3 years ago
- Comments:13 (6 by maintainers)
Top Results From Across the Web
Dynamically adding buttons to toolbar with click handlers
Dynamically adding buttons to toolbar with click handlers · $(document).ready( function () { · $.post( "/FileReview/DisplayToolbar/" + @ViewBag.
Read more >ExtJS 4.1 - How to add items to toolbar dynamically?
Is your event handler getting fired? Try adding console.log(win) in the function and see if anything comes out when you show your window....
Read more >Changing toolbars dynamically at runtime - CodeProject
F ollow the steps below. Create 3 separate Bitmaps in the resource editor with the size to fit the number of buttons on...
Read more >How to add toolbar tab menu items programmatically
We are looking for a way to add the report names to the dropdown menu of the “Open” toolbar tab at the same...
Read more >Add Event Handlers to Dynamically Created Toolbar - ZK Fiddle
<toolbarbutton target="_zkdemo" image="/widgets/tabbox/scrollable/img/balloon-facebook-left.png" href="http://www.facebook.com/zk.framework" />.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@Eraldo I am very interested in the outcome of this exchange. Unfortunately, I have no idea how to help you solve this problem. Maybe you could create an example on Github that we can retrieve for test/debugging?
Regarding #1070: I turned off the custom toolbar template for now, so that should not have to do with it at the moment.
It is not executed at all.