muhammad Yousaf
muhammad Yousaf

Reputation: 73

I want to insert <image> tag into mxgraph using jquery

I want to insert image tag to mxGraph with the help of jQuery.

 $(this).parent().append('<image class="rep" xlink:href="'+src+'" width="25px" height="25px" />');

I am doing above, but the tag inserted is always changed to "<img>" while i want the "<image>" tag. Any idea how I can achieve that. The issue is that the tag inserted is always while for some reasons i need tag, as XML do understand not

Upvotes: 0

Views: 26

Answers (1)

muhammad Yousaf
muhammad Yousaf

Reputation: 73

var newImageElement = document.createElementNS('http://www.w3.org/2000/svg', 'image');
newImageElement.setAttributeNS(null,'width', 25);
newImageElement.setAttributeNS(null,'height', 25);
newImageElement.setAttributeNS(null,'x', x);
newImageElement.setAttributeNS(null,'y', y);
newImageElement.setAttributeNS('http://www.w3.org/2000/svg','xlink:href', src);
$(this).parent().append(newImageElement);

This is resolved using above. But now image does not appear. But if i inspect the HTML of mxGraph editor, it shows the image tag, but image is not appearing.

Upvotes: 0

Related Questions