Find data associated with text element in kinetic javascript in popus

84 views Asked by At
var text = new Kinetic.Text({
    x: a,
    y:  b,
    text: {"name":"WAERK","key":"","description":"SD Document Currency"}.name,
    fontSize: d,
    fontFamily: 'Calibri',
    fill: e ,
    id:"text"+textcount++
});

On clicking the text element I want "description":"SD Document Currency" in popup please help me.

1

There are 1 answers

0
truefusion On

You have to store the information if you want to retrieve it. For example,

var text = new Kinetic.Text({
    x: a,
    y:  b,
    text: "WAERK",
    fontSize: d,
    fontFamily: 'Calibri',
    fill: e ,
    id:"text"+textcount++,
    description: 'SD Document Currency'
});

or text.setAttr('description', description);. (Note, using the setAttr(s) method allows us to listen for the descriptionChange event on the Text object if you ever need to.) You can then retrieve the description with text.getAttr('description'); or text.attrs.description;. Then just pass that into alert or whatever pop-up you're using.