Created
April 19, 2016 11:42
-
-
Save sinslav/4cd01ee1cc4c22c0eb5f85c0aa36459f to your computer and use it in GitHub Desktop.
backbone file validation
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
File = Backbone.Model.extend | |
validate: (args) -> | |
result | |
if [email protected](args) | |
result = 'File already in list' | |
result | |
Files = Backbone.Collection.extend | |
model: File | |
isUniqueFile: (file) -> | |
found | |
for f in @models | |
if f.get('name') is file.name | |
found = f | |
break | |
if found | |
false | |
else | |
true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment