3vot-model
Version:
3VOT Model based on SpineJS
66 lines (43 loc) • 1.19 kB
text/coffeescript
_3Model = require('3vot-model')
AjaxUtils = require("./ajax_utils")
Collection = require("./ajax_collection")
Singleton = require("./ajax_singleton")
Action = require("./ajax_action")
View = require("./ajax_view")
ajax_request = require("./ajax_request")
Include =
ajax: -> new Singleton(this)
url: (args...) ->
args.unshift(encodeURIComponent())
AjaxUtils.generateURL(@, args...)
Extend =
ajax: -> new Collection(this)
view: -> new View(this)
action: -> new Action(this)
url: (args...) ->
AjaxUtils.generateURL(@, args...)
Ajax =
extended: ->
Extend
Include
# Private
ajaxFetch: ->
.fetch(arguments...)
callAction: ->
.call(arguments...)
callView: ->
.call(arguments...)
destroy: ->
.destroy(arguments...)
Ajax.Auto =
extended: ->
# Private
ajaxChange: (record, type, options = {}) ->
return if options.ajax is false
record.ajax()[type](options.ajax || {}, options)
if !_3Model.Model.host then _3Model.Model.host = ""
#for testing
Ajax.request = ajax_request;
module.exports = Ajax