Commit 8cef4f42 by Prem Sichanugrist

Pass in the model into the view when create it

parent a9aa5d9e
......@@ -2,8 +2,5 @@ class CMS.Views.Module extends Backbone.View
events:
"click .module-edit": "edit"
initialize: ->
@model = new CMS.Models.Module(id: @$el.data('id'), type: @$el.data('type'))
edit: =>
CMS.replaceView(new CMS.Views.ModuleEdit(model: @model))
CMS.replaceView(new CMS.Views.ModuleEdit(model: new CMS.Models.Module(id: @$el.data('id'), type: @$el.data('type'))))
......@@ -19,7 +19,6 @@ class CMS.Views.ModuleEdit extends Backbone.View
cancel: ->
CMS.popView()
editSubmodule: (event) =>
$el = $(event.target)
model = new CMS.Models.Module(id: $el.data('id'), type: $el.data('type'))
CMS.pushView(new CMS.Views.ModuleEdit(model: model))
editSubmodule: (event) ->
event.preventDefault()
CMS.pushView(new CMS.Views.ModuleEdit(model: new CMS.Models.Module(id: $(event.target).data('id'), type: $(event.target).data('type'))))
......@@ -3,7 +3,6 @@ class CMS.Views.Week extends Backbone.View
'click .week-edit': 'edit'
initialize: ->
@model = new CMS.Models.Week(id: @$el.data('id'))
@setHeight()
@$('.editable').inlineEdit()
@$('.editable-textarea').inlineEdit(control: 'textarea')
......@@ -15,7 +14,7 @@ class CMS.Views.Week extends Backbone.View
CMS.on('content.hide', @setHeight)
edit: =>
CMS.replaceView(new CMS.Views.WeekEdit(model: @model))
CMS.replaceView(new CMS.Views.WeekEdit(model: new CMS.Models.Week(id: @$el.data('id'))))
setHeight: =>
@$el.height(@options.height)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment