gpt4 book ai didi

javascript - 如何在同一模式窗口中创建 3 个步骤?

转载 作者:搜寻专家 更新时间:2023-10-31 21:06:43 25 4
gpt4 key购买 nike

我需要在同一个模态窗口中创建 3 个步骤。

  1. 寻找发起人。
  2. 选择此发起人的事件。
  3. 在此选定事件中安装设备。

PHP 代码加载步骤并在模式中向我显示一些内容,我尝试了各种形式但找不到解决方案,例如我尝试了 jQuery .load() 但无济于事。有什么帮助吗?谢谢!

我的模式:

<script>
$('#exampleModal').on('show.bs.modal', function (event) {
$( "#modal-content" ).load( "{{ path("agc_asistente_actividad", {"paso": "1"}) }}" );
})
</script>

<div class="modal fade bs-example-modal-lg" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel">
<div class="modal-dialog modal-lg">
<div id="modal-content" class="modal-content">

</div>
</div>
</div>

Controller :

public function asistenteActividadAction($paso, Request $request){
switch($paso){
case "1" :
return $this->render('AgcBackendBundle:asistente:paso1.html.twig');
case "2" :
$data = $request->request->get('data');
$promotor = $data["promotor"];
echo $promotor;
return $this->render('AgcBackendBundle:asistente:paso2.html.twig');
default:
return $this->render('AgcBackendBundle:asistente:paso1.html.twig');
}
}

paso1.html.twig

<script>
$('#next').click(function() {
var data = [];
data["promotor"] = $( "#recipient-promotor" ).val();
$( "#modal-content" ).load( {{ path("agc_asistente_actividad", {"paso" : "2"}) }} + "/"+data);
});
</script>
<div id="all">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="exampleModalLabel">Primer paso. <small>Localice al promotor titular de la actividad donde desea instalar el equipo</small></h4>
</div>
<div class="modal-body">
<ol class="breadcrumb">
<li class="active">Paso 1</li>
</ol>
<label for="recipient-promotor" class="control-label">DNI/CIF: </label>
<input type="text" class="form-control" id="recipient-promotor">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button>
<button type="button" id="next" class="btn btn-primary">Buscar</button>
</div>
</div>

paso2.html.twig(不加载)

<script>
$('#next').click(function() {
var data = [];
data["promotor"] = $( "#recipient-promotor" ).val();
$( "document" ).load( {{ path("agc_asistente_actividad", {"paso" : "3"}) }} + "/"+data);
});
</script>
<div id="all">
<h1>prueba</h1>
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="exampleModalLabel">Segundo paso. <small>Localice al promotor titular de la actividad donde desea instalar el equipo</small></h4>
</div>
<div class="modal-body">
<ol class="breadcrumb">
<li class="active">Paso 1</li>
</ol>
<label for="recipient-promotor" class="control-label">DNI/CIF: </label>
<input type="text" class="form-control" id="recipient-promotor">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button>
<button type="button" id="next" class="btn btn-primary">Buscar</button>
</div>
</div>

最佳答案

将您的 3 个步骤放在同一模式下的不同 div 下(其中 2 个将始终隐藏)。然后您将使用一些快速的 jQuery 前进到下一步的 div。

需要 CSS:

.hideMe {display: none;}

需要 jQuery:

$("#btnEndStep1").click(function () {
$("#step1").addClass('hideMe');
$("#step2").removeClass('hideMe');
});
$("#btnEndStep2").click(function () {
$("#step2").addClass('hideMe');
$("#step3").removeClass('hideMe');
});
$("#btnEndStep3").click(function () {
// Whatever your final validation and form submission requires
$("#sampleModal").modal("hide");
});

保持简单和紧凑。这是一个例子 - https://jsfiddle.net/32rL6gxk/

关于javascript - 如何在同一模式窗口中创建 3 个步骤?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31132044/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com