H
H
Hoffman_ZZZ2016-04-05 17:02:40
JavaScript
Hoffman_ZZZ, 2016-04-05 17:02:40

How to save object parameters in fabric.js and then load the given object with these parameters?

Good evening!
there is a link to the constructor .
When you type in the input field, the text on the T-shirt appears. Then we press the "see back" button, the reverse side appears.
Then we click on the "see front" button and enter the text in the input. The old text is preserved and the new text is overlaid on top of it.
Question:
How to implement so that the text is not superimposed, but the one that was entered earlier is edited?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Zakharov, 2016-04-05
@konratnox

You can add an identifier to the created text like this

var textCanvas = new fabric.IText(text, { 
                      id:'inscription'
                    });

When you press the button, go through the elements of the canvas, change the inscriptions
for (var i = 0; i < canvas._objects.length; i++) {
        		if(canvas.item(i).id == 'inscription') {
        			// заменить текст
        		}
        	}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question