Articles in this section

How To change HTML content into HTML Template in drop event

This article explains how to change HTML content into an HTML template during a drop event.

We don’t have direct support to render HTML template nodes in the symbol palette. However, we can render HTML content nodes inside the symbol palette. Refer to the code below to render HTML content nodes inside the palette:

let palettes = [
 {
   id: 'flow',
   expanded: true,
   title: 'HTML Shapes',
   symbols: [
     {
       id: 'node1',
       shape: {
         type: 'HTML',
         content:
           '<div className="test" style="width:100%"><input type="button" id="button" value=Button></div>',
       },
     },
     {
       id: 'node2',
       shape: {
         type: 'HTML',
         content:
           '<div ><input type="test" style="width:100%"  id="string" value=Input></div>',
   
       },
     },
   ],
 },
]; 

After rendering the HTML content, to change the node to an HTML template node type, we can utilize the drop event. Before that, define the template you need to render and bind the template to the nodeTemplate property of the diagram. Now, in the drop event, we can change the element content to empty and call the diagram.dataBind method. Refer to the code below to learn how to change the HTML content node to a template:

var itemVue = app.component('nodeTemplate', {
 data: () => ({}),
 template: `<div ><button type="button" style="width:100px">node</button></div>`,
}); 
function drop(args) {
 if (args.element.id.includes('node')) {
   args.element.shape.content = '';
   diagram.dataBind();
 }
} 

Refer to the working sample for additional details and implementation:Sample

Conclusion

We hope you enjoyed learning how to change HTML content into HTML template in drop event in Vue diagram.

You can refer to our Vue Diagram feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our Vue Diagram example to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, BoldDesk Support, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Access denied
Access denied