我想实现跳转到功能。它基本上就像一个面包棒但不完全一样。它是dropdown
,可以有左右按钮。请参阅下面的代码:
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<div class="btn-group" role="group" aria-label="...">
<a href="previousItemIfHas" class="btn btn-default">←</a>
<div class="btn-group" role="group">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Jump to
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li><a href="#">Assignment1</a></li>
<li><a href="#">Quiz2</a></li>
<li><a href="#">Quiz4</a></li>
<li><a href="#">Assignment2</a></li>
</ul>
</div>
<a href="nextItemIfHas" class="btn btn-default">→</a>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
&#13;
控制器
$course = Course::with([
'assignments' => $undeleted,
'quizzes' => $undeleted,
'add_links' => $undeleted
])->findOrFail($course_id);
$course_items = collect($course->assignments);
$course_items = $course_items->merge(collect($course->quizzes));
$course_items = $course_items->merge(collect($course->add_links));
$course_items = $course_items->sortBy('item_number');
结果需要:
如果$course
循环,它可以列出按item_number
排序的项目。如果您点击第一项,则应该否 left arrow
,与最后一项相同,如果您点击最后一项,则应该否 right arrow
。项目列表列在我创建的dropdown
。
问题
如果item
是第一项,我不知道如何添加条件,因此我可以删除左键,与最后一项相同。
注意:我正在使用laravel 5.1
答案 0 :(得分:0)
我认为你在模板中的意思是:
你可以使用
@foreach ($users as $user)
<p>This is user {{ $user->id }}</p>
@endforeach
在“foreach”循环中你有变量循环
@foreach ($users as $user)
@if ($user == reset($users ))
This is the first iteration.
@endif
@if ($user == end($users))
This is the last iteration.
@endif
<p>This is user {{ $user->id }}</p>
@endforeach
所以你可以看到第一个或最后一个项目
更多:
答案 1 :(得分:0)
它将以没有prev按钮开始,当你点击任何东西有prev,prev会显示,当你点击任何没有nex时,下一个将被隐藏......等等..
将id =“next”发给next,将id =“prev”发给prev按钮
getAllImageUrls().forEach { url -> GlideApp.with(context)
.load(url)
.apply(RequestOptions().diskCacheStrategy(DiskCacheStrategy.ALL))
// request listener added for debug process
.listener(object: RequestListener<Drawable> {
override fun onLoadFailed(e: GlideException?, model: Any?, target: Target<Drawable>?, isFirstResource: Boolean): Boolean {
...
return true
}
override fun onResourceReady(resource: Drawable?, model: Any?, target: Target<Drawable>?, dataSource: DataSource?, isFirstResource: Boolean): Boolean {
// logging onResourceReady and data source here
return true
}
})
.signature(IntegerVersionSignature(version))
// preloads image into cache using original dimensions
.preload()}