Sha256: 47925972988699d890c5f04fa899d3d6cf1037a5d262413710e9242db3f9f14c

Contents?: true

Size: 825 Bytes

Versions: 2

Compression:

Stored size: 825 Bytes

Contents

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

  events:
    "change input" : "change_handler"

  className: 'luca-ui-checkbox-field luca-ui-field'
  template: 'fields/checkbox_field'
  hooks: ["checked","unchecked"]
  send_blanks: true

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

    if me.is(":checked")
      @trigger "checked"
    else
      @trigger "unchecked"

    @trigger "on:change", @, e, me.is(":checked")

  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.is(":checked")

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
luca-0.9.42 src/components/fields/checkbox_field.coffee
luca-0.9.4 src/components/fields/checkbox_field.coffee