Created
October 31, 2014 19:33
-
-
Save watcherdm/b2191252b51418135001 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define [ | |
'ConsoleFactory' | |
'oraculum/mixins/evented-method' | |
'oraculum/mixins/listener' | |
'select2' | |
], (ConsoleFactory) -> | |
ConsoleFactory.defineMixin 'Select2.ViewMixin', { | |
mixinOptions: | |
select2: {} | |
eventedMethods: | |
attach: {} | |
listen: | |
'attach:after this': 'select2' | |
'dispose:before this': 'destroySelect2' | |
mixconfig: (mixinOptions = {select2}, {select2Options}) -> | |
if _.isFunction select2 | |
orig = select2 | |
mixinOptions.select2 = -> | |
orig select2Options | |
_.extend select2, select2Options | |
select2: -> | |
options = @mixinOptions.select2 | |
options = options.call this if _.isFunction options | |
@$el.select2 options | |
destroySelect2: -> | |
@$el.data('select2')?.destroy() | |
}, { | |
mixins: [ | |
'EventedMethod.Mixin', | |
'Listener.Mixin' | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment