Sha256: f4a66fdee181fe95d6a3149416c91d8641ef5c6f044525eb176e471d39c737c8

Contents?: true

Size: 1.12 KB

Versions: 9

Compression:

Stored size: 1.12 KB

Contents

class App.View extends Backbone.View
  
  destroy: =>
    # give a chance to subclasses before they die
    @onBeforeDestroy()
    # remove view's delegated events (the ones you add inside events: {})
    @undelegateEvents()
    # release anything subscribed to this with @on
    @off()
    # removes the view from the DOM and calls @stopListening()
    @remove()
  
  onBeforeDestroy: ->
    undefined

  forceChromeRepaint: =>
    # ugly ugly ugly h4x0r shit for ugly ugly chrome
    @$el[0].style.display = 'none'
    @$el[0].offsetHeight
    @$el[0].style.display = '';
  
  # converts the containing form to model attributes and values
  # use this when updating models with @model.set @serializeForm()
  serializeForm: =>
    obj = {}
    # one form per view or I'll hunt you down and kill you
    _.each @$('form').serializeArray(), (el) ->
      # Rails array params shenanigans
      if el.name.match /\[\]/
        name = el.name.replace('[', '').replace(']', '')
        if typeof obj[name] == 'undefined'
          obj[name] = [el.value]
        else
          obj[name].push el.value
      else
        obj[el.name] = el.value
    obj

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
frenerator-0.3.0 lib/generators/frenerator/frontend/templates/javascripts/base/view.coffee
frenerator-0.2.3 lib/generators/frenerator/frontend/templates/javascripts/base/view.coffee
frenerator-0.2.2 lib/generators/frenerator/frontend/templates/javascripts/base/view.coffee
frenerator-0.2.1 lib/generators/frenerator/frontend/templates/javascripts/base/view.coffee
frenerator-0.2.0 lib/generators/frenerator/frontend/templates/javascripts/base/view.coffee
frenerator-0.1.4 lib/generators/frenerator/frontend/templates/javascripts/base/view.coffee
frenerator-0.1.3 lib/generators/frenerator/frontend/templates/javascripts/base/view.coffee
frenerator-0.1.2 lib/generators/frenerator/frontend/templates/javascripts/base/view.coffee
frenerator-0.1.1 lib/generators/frenerator/frontend/templates/javascripts/base/view.coffee