Attributes in kendo template not being replaced correctly for custom tools for Kendo editor jp

1 Answer 24 Views
Editor
James
Top achievements
Rank 1
Iron
James asked on 22 Feb 2024, 07:54 PM | edited on 22 Feb 2024, 08:23 PM

Hello,

I am debugging my code using Kendo Dojo example, https://demos.telerik.com/kendo-ui/editor/custom-tools, then click "Edit in Kendo UI Dojo" https://dojo.telerik.com/uyaWeQeb .

 

Here's the code I added to the example in tools array:

                                                                       


                  ,{
                        name: "addTagv2",

                        tooltip: "Add a tag/segment",
                        label: "tag/segment",
                        template: '<button style="padding-left: 5px !important;" type="button" name="#: name #" title="#: tooltip #">#: label #</button>'

                    },
                  {
                        name: "editTagv2",

                        tooltip: "Edit a tag/segment",
                        label:"tag/segment",
                        template:'<button style="padding-left: 5px !important;" type="button" name="#: name #" title="#: tooltip #">#: label #</button>'
                    }                                                                       

 

 

However, when I inspect the buttons I see the following HTML rendered:

<button style="padding-left: 5px !important;" type="button" name="Dojo output" title="Add a tag/segment" tabindex="-1">tag/segment</button>

<button style="padding-left: 5px !important;" type="button" name="Dojo output" title="Edit a tag/segment" tabindex="-1">tag/segment</button>

 

Where is "Dojo output" coming from?  Is "name" a reserved word or property for the tool button.

 

 

Thanks,

James

 

 

 

Thanks,

James

 

 

 

1 Answer, 1 is accepted

Sort by
0
Accepted
James
Top achievements
Rank 1
Iron
answered on 26 Feb 2024, 11:02 PM

Hi,

 

I found out where "Dojo output" is coming : I noticed that the iframe containing the editor is

 

<iframe name="Dojo output" sandbox="allow-modals allow-forms allow-pointer-lock allow-popups allow-same-origin allow-scripts allow-downloads" style="transform: translateZ(0px);"></iframe>

I still do not understand the reason for this name being applied to the Kendo template.

 

Any would be appreciated.

 

 

James

Georgi Denchev
Telerik team
commented on 27 Feb 2024, 11:40 AM

Hi, James,

The templates are evaluated in the global context so they have access to global variables. In this case, the #: name # property points to the global `window.name` which is indeed 'Dojo output'. You can also `console.log` it outside of the editor and you'll get the same result.

For the templates in particular, you could access properties through the data variable:

#: data.tooltip #
#: data.label #

The `name` property in particular is reserved, so you won't have access to it there. You could #: console.log(data) # to see all of the properties that you can access from within the template.

Best Regards,

Georgi

James
Top achievements
Rank 1
Iron
commented on 28 Feb 2024, 05:08 AM

Thanks Georgi,

 

Best Regards,

James

Tags
Editor
Asked by
James
Top achievements
Rank 1
Iron
Answers by
James
Top achievements
Rank 1
Iron
Share this question
or