blob: 61a2af6b1c1eec3080057012455039ed9a251197 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
class csx.Views.ErrorView extends Backbone.View
initialize: (options) ->
@attributesWithErrors = options.attributesWithErrors
_.bindAll(@, "clearOldErrors", "renderErrors", "renderError", "fieldFor")
render: () ->
@clearOldErrors()
@renderErrors()
clearOldErrors: () ->
@$(".error").removeClass("error")
@$("p.inline-errors").remove()
renderErrors: () ->
_.each(@attributesWithErrors.errors, @renderError)
renderError: (errors, attribute) ->
errorString = errors.join(", ")
field = @fieldFor(attribute)
errorTag = $('<p>').addClass('inline-errors').text(errorString)
field.append(errorTag)
field.addClass("error")
fieldFor: (attribute) ->
@$("#cake_#{attribute}").parent()
|