Skip to content

Instantly share code, notes, and snippets.

@qrg
Last active August 29, 2015 14:00
Show Gist options
  • Save qrg/11319317 to your computer and use it in GitHub Desktop.
Save qrg/11319317 to your computer and use it in GitHub Desktop.
# mixin ---------------------------------------------
mixins = require 'mixins'
module.exports = mixins.foo =
bindings:
'.js-mixin-binding-target': 'someModelAttr'
mixinMethod: ->
# do something
# view ---------------------------------------------
View = require 'views/base/view'
mixins = require 'mixins'
module.exports = class BarView extends View
_(@prototype).extend mixins.foo
_(@prototype.bindings).extend
'.js-view-binding-target': 'otherModelAttr'
viewMethod: ->
# do something
@qrg
Copy link
Author

qrg commented Apr 26, 2014

_.deepExtend というのがあった

# view ---------------------------------------------
View = require 'views/base/view'
mixins = require 'mixins'

module.exports = class BarView extends View

  bindings:
    '.js-view-binding-target': 'otherModelAttr'

 _(@prototype).deepExtend mixins.foo

  viewMethod: ->
    # do something

$.extend true, @prototype, mixins.foo でもやってることは同じ?

@qrg
Copy link
Author

qrg commented Apr 26, 2014

とおもったら、 _.deepExtend が利用できるのは、powmedia/backbone-deep-model を入れてるせいだった

backbone-deep-model/lib/underscore.mixin.deepExtend.js at master · powmedia/backbone-deep-model

@qrg
Copy link
Author

qrg commented Apr 26, 2014

backbone-deep-model を将来的に使わなくなって uninstall したときに動かなくなるのも困るので、結局 jquery の extend を利用することにした

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment