Skip to content

Instantly share code, notes, and snippets.

@martinjlowm
Created January 23, 2012 10:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save martinjlowm/1662449 to your computer and use it in GitHub Desktop.
Save martinjlowm/1662449 to your computer and use it in GitHub Desktop.
Altered Page Editor (Mercury)
class @Mercury.CustomPageEditor extends @Mercury.PageEditor
constructor: ->
super
save: ->
url = @saveUrl ? Mercury.saveURL ? @iframeSrc()
data = @serialize()
Mercury.log('saving', data)
data = jQuery.toJSON(data) unless @options.saveStyle == 'form'
method = Mercury.saveMethod || "POST"
console.log(method)
jQuery.ajax url, {
headers: Mercury.ajaxHeaders()
type: method
dataType: @options.saveDataType || 'json'
data: {content: data, _method: method}
success: =>
Mercury.changes = false
Mercury.trigger('saved')
callback() if typeof(callback) == 'function'
error: =>
Mercury.notify('Mercury was unable to save to the url: %s', url)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment