Reputation: 1
I have a problem with fabricj and canvas. I write functions:
var canvas = new fabric.Canvas('c');
jq().ready(function(){
jq("#addText").click(function(){
var text = new fabric.Text(jq("#textCanvas").val(), { left: 0, top: 0 });
text.setColor(jq("#textColor option:checked").val());
text.setFontSize(jq("#textSize option:checked").val());
text.setFontFamily(jq("#fontFamily option:checked").val());
canvas.add(text);
})
jq is no conflict with $. When I try add text in firefox I can, but when I try in Opera, Chrome, or Safari I can't. I have not got information about bugs.
Have you any idea?
Upvotes: 0
Views: 153
Reputation: 1028
You are missing the canvas.renderAll() method.
var canvas = new fabric.Canvas('c');
$().ready(function(){
$("#addText").click(function(){
var text = new fabric.Text($("#textCanvas").val(), { left: 0, top: 0 });
// text.setColor($("#textColor option:checked").val());
// text.setFontSize($("#textSize option:checked").val());
// text.setFontFamily($("#fontFamily option:checked").val());
canvas.add(text);
canvas.renderAll();
});
});
See working example
Upvotes: 1