External module loading

This commit is contained in:
Prem Sichanugrist
2012-06-28 16:15:00 -04:00
parent 7c044aa18a
commit a7dc045f36
4 changed files with 12 additions and 6 deletions

View File

@@ -1,3 +1,9 @@
class CMS.Models.Module extends Backbone.Model
initialize: ->
try
@module = new window[@get('type')](@get('id'))
catch TypeError
console.error "Unable to load #{@get('type')}." if console
editUrl: ->
"/edit_item?id=#{@get('id')}"
"/edit_item?#{$.param(id: @get('id'))}"

View File

@@ -3,7 +3,7 @@ class CMS.Views.Module extends Backbone.View
"click .module-edit": "edit"
initialize: ->
@model = new CMS.Models.Module(id: @el.id)
@model = new CMS.Models.Module(id: @$el.data('id'), type: @$el.data('type'))
edit: =>
CMS.trigger('showContent', new CMS.Views.ModuleEdit(model: @model))

View File

@@ -3,4 +3,4 @@ class CMS.Views.WeekEdit extends Backbone.View
className: 'edit-pane'
initialize: ->
CMS.trigger 'week.edit'
CMS.trigger('week.edit')