有我这个选择权在这里:从选择中选择一个项目后打开模型? Laravel
{!! Form::open(['action' => '[email protected]', 'method' => 'post']) !!}
{!! Form::select('product_id', $products) !!}
{!! Form::close() !!}
$产品变量:
$products = Products::lists('name', 'id')->toArray();
现在我有一个工作模型。我已经在我的另一个项目中使用了图像模型。
其它项目的模式,我想用:
打开模型:
@foreach($themes as $thema)
<a style="cursor: pointer" data-toggle="modal" data-target="#{{ $thema->id }}">
<span class="text">{{ $thema->thema }}<br></span>
</a>
@endforeach
的型号:
@foreach($themes as $thema)
<div class="modal fade" id="{{ $thema->id }}" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
// not important
</div>
<div class="modal-body">
// not important
</div>
</div>
</div>
</div>
@endforeach
我的问题是,我不能”弄清楚如何通过点击打开模型我已选择的项目。当我点击选择框中的某个项目时,就会出现类似的情况,模型会弹出。
或创建一个获取product_id的按钮,并在模型被打开时打开该模型。
我在Javascript中的知识是为了创建这个,也许有另一种方式,但我还找不到。
感谢您的帮助!
使用这种方法,如果数据在数据库中增长,最终会在页面中出现大量模态。为什么不用一个模式并在单击后用数据填充它的内容,可能还需要AJAX调用。 – Michel
我很乐意这样做,但是我在JS/AJAX方面的技能还不足以实现这一点。 – WellNo
在我看来,AJAX将是最好的解决方案。一个快速而肮脏的方法是在加载页面时将所有主题传递给JavaScript数组,并渲染一个模式。当单击数据切换链接打开模式时,可以使用JavaScript/jQuery更新模式的内容,并根据链接中主题的ID将其设置为正确的主题。 – piscator