External module loading
This commit is contained in:
@@ -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'))}"
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -3,4 +3,4 @@ class CMS.Views.WeekEdit extends Backbone.View
|
||||
className: 'edit-pane'
|
||||
|
||||
initialize: ->
|
||||
CMS.trigger 'week.edit'
|
||||
CMS.trigger('week.edit')
|
||||
|
||||
Reference in New Issue
Block a user