Sha256: 8f7218115b2ec88463324b67f10acd9f4d9c2666fb6a5a8dd28d62700f682635

Contents?: true

Size: 688 Bytes

Versions: 1

Compression:

Stored size: 688 Bytes

Contents

require "lib/jquery"

#
# @author - Tim Shelburne <tim@musiconelive.com>
#
# represents a single element in a form
#
class FormElement
  constructor: (@name, @value, @selector, @validationRules = [])->

  addError: (error)->
    $(@selector).closest("li").addClass("invalid")
    $(@selector).closest("li").find("aside.tooltip").html(error.message)
    $(@selector).focus -> $(this).closest("li").addClass("focused")
    $(@selector).blur -> $(this).closest("li").removeClass("focused")

  clearError: ->
    $(@selector).closest("li").removeClass("invalid")
    $(@selector).closest("li").find("aside.tooltip").html("")
    $(@selector).unbind("focus").unbind("blur")

return FormElement

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hoarder-js-0.0.1 assets/scripts/coffee/hoarder/form/form_element.coffee