-
-
Save kmizu/5432467 to your computer and use it in GitHub Desktop.
This file contains hidden or 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