Sha256: b0abd167af1ce5f2af797402bd04467ee22ffb9a69eab1c4f1ff1d5de5486af8
Contents?: true
Size: 1.22 KB
Versions: 3
Compression:
Stored size: 1.22 KB
Contents
# bootstrap-editable-rails.js.coffee # Modify parameters of X-editable suitable for Rails. jQuery ($) -> EditableForm = $.fn.editableform.Constructor EditableForm.prototype.saveWithUrlHook = (value) -> originalUrl = @options.url resource = @options.resource @options.url = (params) => # TODO: should not send when create new object if typeof originalUrl == 'function' # user's function originalUrl.call(@options.scope, params) else if originalUrl? && @options.send != 'never' # send ajax to server and return deferred object obj = {} obj[params.name] = params.value # support custom inputtypes (eg address) if resource params[resource] = obj else params = obj delete params.name delete params.value delete params.pk $.ajax($.extend({ url : originalUrl data : params type : 'PUT' # TODO: should be 'POST' when create new object dataType: 'json' }, @options.ajaxOptions)) @saveWithoutUrlHook(value) EditableForm.prototype.saveWithoutUrlHook = EditableForm.prototype.save EditableForm.prototype.save = EditableForm.prototype.saveWithUrlHook
Version data entries
3 entries across 3 versions & 1 rubygems