FancyBox v2 - login box

前端 未结 2 2101
心在旅途
心在旅途 2020-12-04 00:55

I\'ve readed and went trough all examples on: - http://fancyapps.com/fancybox/

There is nothing to help me with making a pop-up login box.

I\'ve checked the

相关标签:
2条回答
  • 2020-12-04 01:40

    In your code, you need to change href : "#login_form" to be href : "#login_form_ajax".

    0 讨论(0)
  • 2020-12-04 01:58

    For v2.x this would work (notice that I commented out what options were changed)

    $(document).ready(function() {
     $("#top-login-button").click(function() {
      $.fancybox({
       href : "#login_form",
       padding : 0,
       // it was onClosed for v1.3.4
       afterClose : function(){
        $("#login_error").hide();
       }
      }); // fancybox
     }); //click
    
     $("#login_form_ajax").bind("submit", function() {
      if ($("#login_name").val().length < 1 || $("#login_pass").val().length < 1) {
       $("#login_error").show();
       $.fancybox.update(); // it was $.fancybox.resize(); for v1.3.4
       return false;
      }
      $.fancybox.showLoading(); // it was $.fancybox.showActivity(); for v1.3.4
      $.ajax({
       type   : "POST",
       cache  : false,
       url    : "/login.php",
       data   : $(this).serializeArray(),
       success: function(data) {
        $.fancybox(data);
       }
      });
      return false;
     }); // bind
    }); // ready
    

    UPDATE (Aug 10, 2012): Added a DEMO for the skeptics.

    0 讨论(0)
提交回复
热议问题