Sha256: 94f7c9b5c0f7ae24fc1193ee5bd0b53354d2182c4fed219eb9d6a5fcb91fef22
Contents?: true
Size: 1.75 KB
Versions: 22
Compression:
Stored size: 1.75 KB
Contents
var ajaxForm = { "obj": null, "onError": function (type, error, data) { ajaxForm.obj.find("[errorType=\"" + type + "\"]").html(error).show().parents(".control-group").addClass("error"); }, "onSubmit": function () { var args = {}; ajaxForm.obj.find("input, select, textarea").attr("disabled", "disabled").each( function () { if ($(this).attr("name") && ($(this).attr("type") != "checkbox" || $(this).attr("checked"))) args[$(this).attr("name")] = $(this).val(); }); ajaxForm.clear(); ajaxForm.obj.find(".loader").show(); $.post(ajaxForm.obj.attr("action"), args, ajaxForm.response, "text"); }, "clear": function() { ajaxForm.obj.find(".errorContainer").hide().parents(".control-group").removeClass("error"); }, "enable": function () { ajaxForm.obj.find("input, select, textarea").removeAttr("disabled"); ajaxForm.obj.find(".loader").hide(); }, "response": function (data, status) { //alert(data); data=data.replace(/<!\[CDATA\[/,'').replace(/]]>/,'');//Rus 07-02-2013 Screening <![CDATA[ ]]> var response = $(data); if (response.find("error").length != 0) { ajaxForm.onError(response.find("type").text(), response.find("error").text(), response); ajaxForm.enable(); } else if (response.find("redirect").length != 0) document.location.href = response.find("redirect").text(); else ajaxForm.onSuccess(response); }, "onSuccess": function() { } }; $.fn.ajaxForm = function(onSuccess, onError) { $(this).submit(function() { ajaxForm.obj = $(this); ajaxForm.onSuccess = onSuccess; if (onError) ajaxForm.onError = onError; ajaxForm.onSubmit(); return false; }); };
Version data entries
22 entries across 22 versions & 1 rubygems