vendor/assets/javascripts/editable/rails.js.coffee in x-editable-rails-1.2.0 vs vendor/assets/javascripts/editable/rails.js.coffee in x-editable-rails-1.2.1
- old
+ new
@@ -1,34 +1,37 @@
jQuery ($) ->
EditableForm = $.fn.editableform.Constructor
EditableForm.prototype.saveWithUrlHook = (value) ->
- url = @options.url
+ originalUrl = @options.url
model = @options.model
nestedName = @options.nested
nestedId = @options.nid
nestedLocale = @options.locale
@options.url = (params) =>
- myName = params.name
- myValue = params.value.replace(/(\r\n|\n|\r)/gm,"<br/>")
- obj = {}
- if nestedName
- nested = {}
- nested[myName] = myValue
- nested['id'] = nestedId
- if nestedLocale
- nested['locale'] = nestedLocale
- obj[nestedName + '_attributes'] = nested
- else
- obj[myName] = myValue
- params[model] = obj
- delete params.name
- delete params.value
- delete params.pk
- $.ajax($.extend({
- url : url
- data : params
- type : 'PUT'
- dataType: 'json'
- }, @options.ajaxOptions))
+ if typeof originalUrl == 'function'
+ originalUrl.call(@options.scope, params)
+ else if originalUrl? && @options.send != 'never'
+ myName = params.name
+ myValue = params.value.replace(/(\r\n|\n|\r)/gm,"<br/>")
+ obj = {}
+ if nestedName
+ nested = {}
+ nested[myName] = myValue
+ nested['id'] = nestedId
+ if nestedLocale
+ nested['locale'] = nestedLocale
+ obj[nestedName + '_attributes'] = nested
+ else
+ obj[myName] = myValue
+ params[model] = obj
+ delete params.name
+ delete params.value
+ delete params.pk
+ $.ajax($.extend({
+ url : originalUrl
+ data : params
+ type : 'PUT'
+ dataType: 'json'
+ }, @options.ajaxOptions))
@saveWithoutUrlHook(value)
EditableForm.prototype.saveWithoutUrlHook = EditableForm.prototype.save
EditableForm.prototype.save = EditableForm.prototype.saveWithUrlHook
\ No newline at end of file