Sha256: 165e51d8959dd5e9ba2ed415824854195d10b1b302817b136157063200d60daf

Contents?: true

Size: 910 Bytes

Versions: 6

Compression:

Stored size: 910 Bytes

Contents

class @Select2Input.RelatedView extends Backbone.View

  tagName : 'li'

  events :
    'click [data-edit]' : 'editRelation'
    'click [data-remove]' : 'removeRelation'

  initialize : () ->
    @model.on 'relation-remove', @remove, this
    @model.on 'change', @render, this

  editRelation : (e) ->
    e.preventDefault()
    FormPopup.Initializer.getInstance().showPopup @model

  removeRelation : (e) ->
    e.preventDefault()
    @model.relationRemove() if confirm I18n.t('rademade_admin.model_remove_confirm')
    false

  render : () ->
    @$el.html @_getHtml(@model.toJSON())
    return this

  _getHtml : (data) ->
    JST['rademade_admin/app/templates/related-item'](data)

  @init : ($el) ->
    model = new Select2Input.RelatedModel
      id : $el.data('id')
      text : $el.find('span').text()
      editurl : $el.find('[data-edit]').data('edit')
    new this
      el : $el
      model : model

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rademade_admin-0.2.2 app/assets/javascripts/rademade_admin/app/select2/related/view.coffee
rademade_admin-0.2.1 app/assets/javascripts/rademade_admin/app/select2/related/view.coffee
rademade_admin-0.2.0 app/assets/javascripts/rademade_admin/app/select2/related/view.coffee
rademade_admin-0.1.6 app/assets/javascripts/rademade_admin/app/select2/related/view.coffee
rademade_admin-0.1.5 app/assets/javascripts/rademade_admin/app/select2/related/view.coffee
rademade_admin-0.1.4 app/assets/javascripts/rademade_admin/app/select2/related/view.coffee