vendor/assets/javascripts/hobo-jquery/hjq.js in hobo_jquery-1.4.0.pre8 vs vendor/assets/javascripts/hobo-jquery/hjq.js in hobo_jquery-2.0.0.pre1

- old
+ new

@@ -236,16 +236,20 @@ } } result.context = this; result.type = o.type || 'GET'; - result.data = {"render_options[preamble]": o.preamble || '', - "render_options[contexts_function]": 'hjq.ajax.updatePartContexts' - }; + result.data = {}; + /* These are now the defaults, so we don't need to send + them over the wire. + result.data = {"render_options[preamble]": o.preamble || '', + "render_options[contexts_function]": 'hjq.ajax.updatePartContexts' + }; */ + if(o.preamble) result.data["render_options[preamble]"] = o.postamble; if(o.postamble) result.data["render_options[postamble]"] = o.postamble; if(o.content_type) result.data["render_options[content_type]"] = o.content_type; - if(o.attrs.errors_ok) result.data["render_options[errors_ok]"] = 1; + if(o.attrs['errors-ok']) result.data["render_options[errors_ok]"] = 1; result.dataType = 'script'; o.spec = jQuery.extend({'function': 'hjq.ajax.update', preamble: ''}, o.spec); var part_data = {}; if(o.attrs.hide!==undefined) part_data.hide = o.attrs.hide; @@ -256,22 +260,23 @@ var ids=methods.getUpdateIds.call(this, o.attrs); for(var i=0; i<ids.length; i++) { if(part_data) $("#"+ids[i]).data('hjq-ajax', part_data); result.data["render["+i+"][part_context]"] = page_data.hobo_parts[ids[i]]; result.data["render["+i+"][id]"] = ids[i]; - result.data["render["+i+"][function]"] = o['function'] || 'hjq.ajax.update'; + // default for render[i][function] is hjq.ajax.update + if(o.function) result.data["render["+i+"][function]"] = o['function']; } return result; }, buildRequestCallbacks: function(result, o) { var that = this; if (!o.attrs) o.attrs = {}; if (!o.extra_callbacks) o.extra_callbacks = {}; - this.hjq_spinner(o.attrs, "Saving..."); + var spinner = this.hjq_spinner(o.attrs, "Saving..."); var success_dfd = jQuery.Deferred(); if(o.attrs.success) success_dfd.done(methods.createFunction.call(that, o.attrs.success)); if(o.extra_callbacks.success) success_dfd.done(methods.createFunction.call(that, o.extra_callbacks.success)); success_dfd.done(function() { @@ -297,10 +302,10 @@ if(o.attrs.complete) complete_dfd.done(methods.createFunction.call(that, o.attrs.complete)); if(o.extra_callbacks.complete) complete_dfd.done(methods.createFunction.call(that, o.extra_callbacks.complete)); complete_dfd.done(function() { if(that.parents("body").length==0) $(document).trigger('rapid:ajax:complete', [that]); else that.trigger('rapid:ajax:complete', [that]); - that.hjq_spinner('remove'); + spinner.hjq_spinner('remove'); if(o.attrs.refocus_form) that.find(":input[type!=hidden]:first").focus(); }); result.complete = complete_dfd.resolve; jQuery.extend(result, o.extra_options);