Sha256: ba68fc31c1c1a7613d5ad2072ae74e1baf8e023fc819f26ab657edaf4bcb7f96
Contents?: true
Size: 1.37 KB
Versions: 2
Compression:
Stored size: 1.37 KB
Contents
#= require resourcy # # Resourcy Ajax adapter # # This overrides the default jQuery.ajax method and mixes in the logic required to make Resourcy work with the options # and arguments for the jQuery Ajax api. # Get the original jQuery.ajax and merge in some additional methods from Resourcy. original = jQuery.ajax jQuery.extend(jQuery, {originalAjax: original, resources: Resourcy.resources, resource: Resourcy.resource, routes: Resourcy.routes}) # Remove Resourcy from the global namespace. handleRequest = Resourcy.handleRequest Resourcy.noConflict() # Define an options handler, that properly merges options for the Ajax request. optionsHandler = (opts1, opts2, defaults = {}) -> options = jQuery.extend(true, {}, opts1, opts2, defaults) for method in ['beforeSend', 'error', 'dataFilter', 'success', 'complete'] if opts1[method] && opts2[method] c1 = opts1[method] c2 = opts2[method] options[method] = -> c1.apply(window, arguments) c2.apply(window, arguments) return options # Create a new jQuery.ajax method that works with Resourcy. jQuery.ajax = (url, options = {}) -> if typeof(url) is 'object' options = url url = options.url for data in options.data || [] if data.name is '_method' method = data.value break return handleRequest(method || options.type || 'get', url, options, jQuery.originalAjax, optionsHandler)
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
resourcy-rails-1.1.1 | vendor/assets/javascripts/jquery.resourcy.js.coffee |
resourcy-rails-1.1.0 | vendor/assets/javascripts/jquery.resourcy.js.coffee |