Sha256: 0911d6e0adb1c24a90b91044cc157d711acf40492adc822e7fda11b7379248df

Contents?: true

Size: 858 Bytes

Versions: 3

Compression:

Stored size: 858 Bytes

Contents

(defineAjaxWithJellyFunctions = function($) {
  $.ajaxWithJelly = function(params) {
    $.ajax($.ajaxWithJelly.params(params));
  };

  if ($.fn.ajaxForm) {
    $.fn.ajaxFormWithJelly = function(params) {
      this.ajaxForm($.ajaxWithJelly.params(params));
    };
  }

  $.ajaxWithJelly.params = function(otherParams) {
    otherParams = otherParams || {};

    if (otherParams.type && otherParams.type != "GET") {
      otherParams['data'] = $.extend(otherParams['data'], {
        authenticity_token: window._token
      });
    }
    return $.extend({
      dataType: 'json',
      cache: false,
      success : $.ajaxWithJelly.onSuccess
    }, otherParams);
  };

  $.ajaxWithJelly.onSuccess = function(json) {
    var context = json.on ? eval(json.on) : page;
    context[json.method].apply(context, json.arguments);
    return true;
  };
})(jQuery);

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
pivotal-jelly-0.5.1 generators/jelly/templates/javascripts/ajax_with_jelly.js
pivotal-jelly-0.5.3 generators/jelly/templates/javascripts/ajax_with_jelly.js
jelly-0.5.4 generators/jelly/templates/javascripts/ajax_with_jelly.js