Skip to content

Instantly share code, notes, and snippets.

@dmitry-ilyashevich
Forked from alovak/shit.coffee
Last active December 20, 2015 11:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dmitry-ilyashevich/6125299 to your computer and use it in GitHub Desktop.
Save dmitry-ilyashevich/6125299 to your computer and use it in GitHub Desktop.
class KoModel
indexed_error_for: (property_name, index, nested_property = null) =>
ko.computed =>
return unless @errors() and error_property = @errors()[property_name]
error = jQuery.grep error_property, (item) ->
item.index == index
return '' unless error and error.length
if nested_property
@join_errors error[0].errors[nested_property]
else
@join_errors error[0].errors
error_for: (property_name) =>
ko.computed =>
@join_errors @errors()[property_name] if @errors()?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment