Created
May 15, 2012 20:36
-
-
Save teamon/2704934 to your computer and use it in GitHub Desktop.
Backbone.js jQuery file upload with autosave
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This will automatically create or update model | |
onRender: => | |
[method, url] = if @model.isNew() | |
["POST", mymodels_path()] | |
else | |
["PUT", model_path(@model.id)] | |
@$(".upload").fileupload( | |
dataType: 'json' | |
type: method | |
url: url | |
formData: {"_method": method} | |
done: (e, data) => | |
@model.set(id: data.result.id) | |
@render() | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment