emin Posted December 23, 2022 Share Posted December 23, 2022 Hi I need extra button in htmlmemo toolbar. I found a script that allows to add a new button to the toolbar. But I need more than that. How can I add the following functions to the new button. - add an image to the button - adding the button in the desired order. this script adds the button at the end Quote function beforeInit(sender, config) { config.listeners = { render: function(editor) { editor.getToolbar().add({ xtype: 'button', text: 'imageUpload', handler: function() { ajaxRequest(sender, 'uploadImage', []) } }); } } } Quote Link to comment Share on other sites More sharing options...
Sherzod Posted December 23, 2022 Share Posted December 23, 2022 Hello, You can try to use insert instead of add, the first parameter will be the index position. Quote Link to comment Share on other sites More sharing options...
emin Posted December 23, 2022 Author Share Posted December 23, 2022 Hi I tried many thinks but none of them worked. Where do I need to add index position and how. config.listeners = { render: function(editor) { editor.getToolbar().insert({ xtype: 'button', text: 'Kaydet', handler: function() { ajaxRequest(sender, 'Kaydet', []) } }); } } Quote Link to comment Share on other sites More sharing options...
Sherzod Posted December 23, 2022 Share Posted December 23, 2022 insert(position, {}) Quote Link to comment Share on other sites More sharing options...
emin Posted December 23, 2022 Author Share Posted December 23, 2022 I tried this way but it doesn't work. Can you please write the full code, and how add an image to new button. Thanks Quote function beforeInit(sender, config) { config.listeners = { render: function(editor) { editor.getToolbar().insert(position, {2}) { xtype: 'button', text: 'imageUpload', handler: function() { ajaxRequest(sender, 'uploadImage', []) } }); } } } Quote Link to comment Share on other sites More sharing options...
Sherzod Posted December 23, 2022 Share Posted December 23, 2022 editor.getToolbar().insert(position, {2}) { xtype: 'button', text: 'imageUpload', handler: function() { ajaxRequest(sender, 'uploadImage', []) } }); } editor.getToolbar().insert(2, { xtype: 'button', text: 'imageUpload', handler: function() { ajaxRequest(sender, 'uploadImage', []) } }) Quote Link to comment Share on other sites More sharing options...
emin Posted December 23, 2022 Author Share Posted December 23, 2022 It works pefrectly. Thank you so much. Is there a solution for adding an image to the added button? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted December 23, 2022 Share Posted December 23, 2022 3 hours ago, emin said: Is there a solution for adding an image to the added button? Quote Link to comment Share on other sites More sharing options...
emin Posted December 23, 2022 Author Share Posted December 23, 2022 It works. Thanks again. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted December 23, 2022 Share Posted December 23, 2022 Very good. Quote Link to comment Share on other sites More sharing options...
emin Posted December 24, 2022 Author Share Posted December 24, 2022 Hi Sherzod If I want to add more than one button. What would be the correct script Quote Link to comment Share on other sites More sharing options...
Sherzod Posted December 24, 2022 Share Posted December 24, 2022 Hello, 9 minutes ago, emin said: If I want to add more than one button. What would be the correct script For example like this: function beforeInit(sender, config) { var indx = 0; config.listeners = { render: function(editor) { editor.getToolbar().insert(indx, { xtype: 'button', text: 'imageUpload1', handler: function() { ajaxRequest(sender, 'uploadImage', []) } }); indx = +1; editor.getToolbar().insert(indx, { xtype: 'button', text: 'imageUpload2', handler: function() { ajaxRequest(sender, 'uploadImage2', []) } }); } } } Quote Link to comment Share on other sites More sharing options...
emin Posted December 24, 2022 Author Share Posted December 24, 2022 You are awesome. Thank you 1 Quote Link to comment Share on other sites More sharing options...
emin Posted February 14, 2023 Author Share Posted February 14, 2023 Hi How can I add to the new button a hint Quote Link to comment Share on other sites More sharing options...
Sherzod Posted February 14, 2023 Share Posted February 14, 2023 Hello, 6 minutes ago, emin said: How can I add to the new button a hint ... text: 'imageUpload1', tooltip: 'Upload...', ... Quote Link to comment Share on other sites More sharing options...
emin Posted February 14, 2023 Author Share Posted February 14, 2023 Thanks Sherzod Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.