Sha256: 187d2f82a2c68bd594b462d46dfba72c1ad6147c5ae7a74ed03fbc8235d9a6ed

Contents?: true

Size: 911 Bytes

Versions: 3

Compression:

Stored size: 911 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()
      edit_url : $el.find('[data-edit]').data('edit')
    new this
      el : $el
      model : model

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rademade_admin-0.1.3 app/assets/javascripts/rademade_admin/app/select2/related/view.coffee
rademade_admin-0.1.2 app/assets/javascripts/rademade_admin/app/select2/related/view.coffee
rademade_admin-0.1.1 app/assets/javascripts/rademade_admin/app/select2/related/view.coffee