Last active
August 29, 2015 14:20
-
-
Save tiborsaas/9937dd83a51597a88108 to your computer and use it in GitHub Desktop.
Dynamic Backbone models
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([ | |
'backbone', | |
'models/export/YouTubeExport', | |
'models/export/ImgurExport' | |
], function ( | |
Backbone, | |
YouTubeExport, | |
ImgurExport | |
) { | |
'use strict'; | |
var ExportModelWrapper = function(options){ | |
var targets = { | |
youtube: YouTubeExport, | |
imgur: ImgurExport | |
}; | |
var target = targets[ options.target ].prototype; | |
var ExportModel = target.constructor.extend({ | |
constructor: function (options) { | |
target.constructor.apply(this, arguments); | |
targets = null; | |
} | |
}); | |
return ExportModel; | |
} | |
return ExportModelWrapper; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment