Created
January 31, 2012 15:11
-
-
Save johnantoni/1710985 to your computer and use it in GitHub Desktop.
ajaxForm_with_fancybox - pulled from a project for dissection
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $.fn.ajaxForm_with_fancybox = function(options) { | |
| $("<input>").attr("type", "hidden").attr("name", "lightbox").val("1").appendTo(this); | |
| var url = jQuery(this).attr("action"); | |
| this.ajaxForm({ | |
| url: url + ".json", | |
| beforeSend: function(request){ | |
| $.fancybox.showLoading(); | |
| }, | |
| error: function(request, textStatus, errorThrown){ | |
| $.fancybox.hideLoading(); | |
| }, | |
| success: function(data, textStatus, request){ | |
| var location = data.location; | |
| if (location !== null && location !== "" && location !== undefined) { | |
| window.location = location; // redirect to page | |
| } else { | |
| // check if main site content, if yes, close and redirect to naked site | |
| if ($(data).find(".logged-in").length > 0) { | |
| $.fancybox.close(true); | |
| window.location = "/"; | |
| } | |
| else { | |
| $.fancybox({ | |
| 'content' : data | |
| }); | |
| } | |
| } | |
| } | |
| }); | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment