9952 explained code solutions for 126 technologies

backbone.jsHow do I use backbone.js to zip a file?

Backbone.js is a JavaScript library that provides structure to web applications. It can be used to create a zip file by using the JavaScript library JSZip.

To use JSZip with Backbone.js, first include the JSZip library in your HTML page:

<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.5/jszip.min.js"></script>

Then, create a new JSZip instance and add files to it:

var zip = new JSZip();
zip.file("Hello.txt", "Hello World\n");

Once all of the files have been added, the zip file can be generated by calling the generateAsync() method:

    .then(function (blob) {
        saveAs(blob, "example.zip");

This will generate a zip file named "example.zip" that contains the file "Hello.txt".

Helpful links

Edit this code on GitHub