Sha256: ef0f2a9bad8fbf4979bd34151736a568c2af29140e53bfd90422dbcffa7c76a1

Contents?: true

Size: 826 Bytes

Versions: 3

Compression:

Stored size: 826 Bytes

Contents

_.def('Luca.fields.CheckboxField').extends('Luca.core.Field').with

  events:
    "change input" : "change_handler"

  change_handler: (e)->
    me = my = $(e.currentTarget)

    @trigger "on:change", @, e

    if me.checked is true
      @trigger "checked"
    else
      @trigger "unchecked"

  className: 'luca-ui-checkbox-field luca-ui-field'

  template: 'fields/checkbox_field'

  hooks: ["checked","unchecked"]

  send_blanks: true

  initialize: (@options={})->
    _.extend @, @options
    _.bindAll @, "change_handler"

    Luca.core.Field::initialize.apply @, arguments

  afterInitialize: ()->
    @input_id ||= _.uniqueId('field')
    @input_name ||= @name
    @input_value ||= 1
    @label ||= @name

  setValue: (checked)->
    @input.attr('checked', checked)

  getValue:()->
    @input.attr('checked') is true

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
luca-0.9.2 src/components/fields/checkbox_field.coffee
luca-0.9.1 src/components/fields/checkbox_field.coffee
luca-0.9.0 src/components/fields/checkbox_field.coffee