Sha256: 9bf773acfddf9972cae52c6b4b9fccb1ca6e9e908e89e33aec0a9bfc8499d158
Contents?: true
Size: 1.97 KB
Versions: 2
Compression:
Stored size: 1.97 KB
Contents
class IuguUI.View extends IuguUI.Base layout: "iugu-ui-view" initialize: -> if @model Backbone.Validation.bind @, forceUpdate: true valid: (view, attr, selector) -> view.valid view, attr, selector invalid: (view, attr, error, selector) -> view.invalid view, attr, error, selector @model.on 'error', @addErrors, @ valid: (view, attr, selector) -> control = view.$ '[' + selector + '=\"' + attr + '\"]' group = control.parents ".form-group" ctrlGroup = control.parents ".control-group" list = group.find ".error-list" return if view.model.preValidate attr, control.val() list.find(".error-" + attr).remove() ctrlGroup.removeClass "error" list.parent().remove() if list.find(".error").length == 0 invalid: (view, attr, error, selector) -> control = view.$ '[' + selector + '=\"' + attr + '\"]' group = control.parents ".form-group" ctrlGroup = control.parents ".control-group" list = group.find ".error-list" ctrlGroup.addClass "error" if list.length == 0 group.prepend '<div class="alert alert-error"><ul class="error-list"></ul></div>' list = group.find ".error-list" list.find(".error-" + attr).remove() if _.isArray(error) _.each(error, (err) -> list.append '<li class="error error-' + attr + '">' + attr + ' ' + err + '</li>' ) else list.append '<li class="error error-' + attr + '">' + error + '</li>' addErrors: (model, errors) -> invalid = @invalid view = @ errors_json = JSON.parse errors.responseText _.each(errors_json.errors, (val, key) -> invalid view, key, val, "name" ) render: -> super rivets.bind this.$el, {model: @model} if @model @ unload: () -> super debug 'Called IuguUI.View:close' if @model Backbone.Validation.unbind @ @model.off null, null, @ if @collection @collection.off null, null, @ @IuguUI.View = IuguUI.View
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
iugu-ux-0.8.6 | vendor/assets/javascripts/iugu-ux/components/usecode/iugu-ui-view.js.coffee |
iugu-ux-0.8.5 | vendor/assets/javascripts/iugu-ux/components/usecode/iugu-ui-view.js.coffee |