2011-11-21 01:27:05 +00:00
|
|
|
class Locomotive.Models.Page extends Backbone.Model
|
|
|
|
|
2011-11-25 01:04:42 +00:00
|
|
|
paramRoot: 'page'
|
|
|
|
|
|
|
|
urlRoot: "#{Locomotive.mount_on}/pages"
|
|
|
|
|
2011-11-21 01:27:05 +00:00
|
|
|
initialize: ->
|
2011-11-25 01:04:42 +00:00
|
|
|
@_normalize()
|
|
|
|
|
|
|
|
_normalize: ->
|
2011-11-21 01:27:05 +00:00
|
|
|
@set
|
|
|
|
editable_elements: new Locomotive.Models.EditableElementsCollection(@get('editable_elements'))
|
|
|
|
|
2011-11-25 01:04:42 +00:00
|
|
|
|
|
|
|
# unless _.isArray @get('editable_elements')
|
|
|
|
# console.log('already a collection')
|
|
|
|
# return
|
|
|
|
#
|
|
|
|
# previous_collection = @previous('editable_elements')
|
|
|
|
#
|
|
|
|
# console.log(previous_collection)
|
|
|
|
#
|
|
|
|
# if _.isArray collection
|
|
|
|
# collection = new Locomotive.Models.EditableElementsCollection(@get('editable_elements'))
|
|
|
|
# else
|
|
|
|
# collection.fetch(@get('editable_elements'))
|
|
|
|
#
|
|
|
|
# @set(editable_elements: collection)
|
|
|
|
|
|
|
|
# @set
|
|
|
|
# editable_elements: new Locomotive.Models.EditableElementsCollection(@get('editable_elements'))
|
|
|
|
|
|
|
|
toJSON: ->
|
|
|
|
_.tap super, (hash) =>
|
|
|
|
hash.editable_elements = @get('editable_elements').toJSONForSave() if @get('editable_elements')
|
|
|
|
|
2011-11-21 01:27:05 +00:00
|
|
|
class Locomotive.Models.PagesCollection extends Backbone.Collection
|