Summary

In this chapter, we have seen how to upload files to the server; this is not the only way to do it, but is the more extended and flexible approach. Another possible method is to serialize the image into base64 in the browser, then set the output string as an attribute in the model; when ten models are saved, the file encoded in base64 will be part of the payload. The server should decode the string and process the result as a file.

We saw how to decouple the view from the business logic. The view should only process DOM events and trigger business logic level events; then a controller can deal with blob objects instead of low-level DOM nodes. This approach helped us to move upload processing from the view to the model, which is the ideal ...

Get Mastering Backbone.js now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.