How to deactivate all objects in Fabric.js
canvas, fabricjs, javascript
Solution
`canvas.deactivateAll();` => no events are fired http://fabricjs.com/docs/fabric.Canvas.html#deactivateAll
or
`canvas.deactivateAllWithDispatch();` => if activeObject exists the events 'before:selection:cleared' and 'selection:cleared' are fired. http://fabricjs.com/docs/fabric.Canvas.html#deactivateAllWithDispatch
Problem
How to deactivate all objects in Fabric.js before saving an image? ``` function rasterize() { if (!myscript.Canvas.supports('toDataURL')) { alert('This browser doesn\'t provide means to serialize canvas to an image'); } else { /*i want to deactivate all object here*/ window.open(canvas.toDataURL('png')); } } ```