2011-11-22 41 views
0

我想在LightBoxes上显示HTML表单。每个灯箱都会有一个按钮。 onClick按钮,一个新的LightBox应该打开一个新的HTML表单。我如何做这样的导航。我发现图像之间的导航,但不是HTML表单。链接LightBox中的LightBox

回答

3

您不需要打开新的灯箱,而是将新窗体的内容加载到当前窗体中。另外,不要从按钮中捕获点击事件,因为如果用户尝试按键盘上的输入提交表单,它就不会起作用。你可以做这样的事情:

$('#lightbox form').submit(function(){ 

    // some validation logic can be here 

    // load the form from another file 
    $('#lightbox').load('step-two-form.html'); 

    // OR insert it from the same document 
    $('#lightbox').html($('#step-two-form')); 

    // and return false for avoid reload the page 
    return false; 
}); 
0

可以让两个独立的div在同一收藏夹内容

<div class="lightbox"> 
    <div id="firstdiv">CONTENT 1 that contains a button to show #seconddiv and hide #firstdiv</div> 
    <div id="seconddiv" class="hidden">CONTENT 2</div> 
</div> 

我已经在这里类似
http://www.klein-associes.com/grand_public/#
点击“ACCES法新社/ DISTRIBUTEUR”的东西然后“s'inscrire”进行演示

$('#firstdiv #button1').click(function(){ 
     $('#firstdiv').fadeOut('fast',function(){ 
      $('#seconddiv').fadeIn('fast'); 
     }); 
});