2013-02-06 2 views
0

다음 링크에서 로그인 모달을 다운로드했습니다. http://www.alessioatzeni.com/blog/login-box-modal-dialog-window-with-css-and-jquery/로드시이 모달 윈도우를 여는 방법 - PHP

CSS에 몇 가지 변경 사항을 적용했지만 그게 전부입니다.

여기에 내가 페이지로드로드이 모달 필요 .. 기본적으로

$(document).ready(function() { 
$('a.loginbutton').click(function() { 

    // Getting the variable's value from a link 
    var loginBox = $(this).attr('href'); 

    //Fade in the Popup and add close button 
    $(loginBox).fadeIn(300); 
    $.fn.formLabels(); //Initialize form labels 

    //Set the center alignment padding + border 
    var popMargTop = ($(loginBox).height() + 24)/2; 
    var popMargLeft = ($(loginBox).width() + 24)/2; 

    $(loginBox).css({ 
     'margin-top' : -popMargTop, 
     'margin-left' : -popMargLeft 
    }); 

    // Add the mask to body 
    $('body').append('<div id="mask"></div>'); 
    $('#mask').fadeIn(300); 

    return false; 
}); 

// When clicking on the button close or the mask layer the popup closed 
$('a.close, #mask').live('click', function() { 
    $('#mask , .login-popup').fadeOut(300 , function() { 
    $('#mask').remove(); 
}); 
return false; 
}); 
    }); 

내가 버튼을 클릭하면 모달 창을 시작하는 jQuery 코드입니다. 간신히 jQuery를 알기 때문에 플러그인을 다운로드 한 이유는 무엇입니까? 나는이 일을 정말로 필요로한다.

이 코드를 작성한 사람에게 이미 연락을 시도했지만 답장을 보내지 않았습니다.

답변

4
$('a.loginbutton').click(); 

페이지가로드 될 때 click 이벤트를 실행하기 위해 해당 행을 추가하기 만하면됩니다.

-1

모달을로드하기 전에 사용자가 로그인 버튼을 클릭하기를 기다리고 있습니다. 이것을 시도하십시오 :

$(document).ready(function() { 
//$('a.loginbutton').click(function() { 

// Getting the variable's value from a link 
var loginBox = $(this).attr('href'); 

//Fade in the Popup and add close button 
$(loginBox).fadeIn(300); 
$.fn.formLabels(); //Initialize form labels 

//Set the center alignment padding + border 
var popMargTop = ($(loginBox).height() + 24)/2; 
var popMargLeft = ($(loginBox).width() + 24)/2; 

$(loginBox).css({ 
    'margin-top' : -popMargTop, 
    'margin-left' : -popMargLeft 
}); 

// Add the mask to body 
$('body').append('<div id="mask"></div>'); 
$('#mask').fadeIn(300); 

return false; 
}); 
// When clicking on the button close or the mask layer the popup closed 
$('a.close, #mask').live('click', function() { 
    $('#mask , .login-popup').fadeOut(300 , function() { 
    $('#mask').remove(); 
}); 
return false; 
//}); 
}); 

.click() 함수를 주석 처리했다고 생각합니다.

안에있는 것 $ (문서) .ready (function() {}); 페이지가로드되면 바로 이 해고됩니다.

$ ('a.loginbutton') 안에있는 모든 항목. (function() {}); 사용자가 해당 버튼을 클릭 할 때만 실행됩니다.

관련 문제