Jquery 引导动态模式中的“上一步”按钮

Jquery 引导动态模式中的“上一步”按钮,jquery,html,css,Jquery,Html,Css,大家好,我正在尝试根据每个团队成员的点击创建一个团队部分。我正在显示一个具有特定成员详细信息的引导模式,我需要帮助使用jquery在模式中添加prev next按钮功能,这里是js fiddle url 测试2 厘米 Tst-1 副总理 这是最新的小提琴: 基本上,当用户单击“下一步”按钮时,您需要查找下一张可用卡,当用户单击“上一张”按钮时,您需要查找上一张可用卡。我通过跟踪openProfile变量中当前打开的modal来实现这一点。单击.next或.prev,您需要找到适用的.prof

大家好,我正在尝试根据每个团队成员的点击创建一个团队部分。我正在显示一个具有特定成员详细信息的引导模式,我需要帮助使用jquery在模式中添加prev next按钮功能,这里是js fiddle url

测试2 厘米 Tst-1 副总理



这是最新的小提琴:

基本上,当用户单击“下一步”按钮时,您需要查找下一张可用卡,当用户单击“上一张”按钮时,您需要查找上一张可用卡。我通过跟踪
openProfile
变量中当前打开的
modal
来实现这一点。单击
.next
.prev
,您需要找到适用的
.profile卡
,并将其内容填充到模式中

$(".next").click(function(event){
  var cards = openProfile.parents('.row').find(".profile-card");
  var currentCardIndex = cards.index(openProfile);
  if(cards.length > (currentCardIndex + 1)) {
    cards.get(currentCardIndex + 1).click();
    setTimeout(function() {
        $("#profileDetail").modal("show");
    },500);
  } else {
    alert("You are on the last card!");
  }
});
但是,当您单击
.profile card
时,由于其上的
模糊事件,打开模式被隐藏。因此,您可以使用
$('profileDetail').modal('show')
再次打开它。但是由于模态隐藏的动画可能正在进行中,您需要等待半秒钟才能重新打开模态

$(".next").click(function(event){
  var cards = openProfile.parents('.row').find(".profile-card");
  var currentCardIndex = cards.index(openProfile);
  if(cards.length > (currentCardIndex + 1)) {
    cards.get(currentCardIndex + 1).click();
    setTimeout(function() {
        $("#profileDetail").modal("show");
    },500);
  } else {
    alert("You are on the last card!");
  }
});

以下是最新的提琴:

基本上,当用户单击“下一步”按钮时,您需要查找下一张可用卡,当用户单击“上一张”按钮时,您需要查找上一张可用卡。我通过跟踪
openProfile
变量中当前打开的
modal
来实现这一点。单击
.next
.prev
,您需要找到适用的
.profile卡
,并将其内容填充到模式中

$(".next").click(function(event){
  var cards = openProfile.parents('.row').find(".profile-card");
  var currentCardIndex = cards.index(openProfile);
  if(cards.length > (currentCardIndex + 1)) {
    cards.get(currentCardIndex + 1).click();
    setTimeout(function() {
        $("#profileDetail").modal("show");
    },500);
  } else {
    alert("You are on the last card!");
  }
});
但是,当您单击
.profile card
时,由于其上的
模糊事件,打开模式被隐藏。因此,您可以使用
$('profileDetail').modal('show')
再次打开它。但是由于模态隐藏的动画可能正在进行中,您需要等待半秒钟才能重新打开模态

$(".next").click(function(event){
  var cards = openProfile.parents('.row').find(".profile-card");
  var currentCardIndex = cards.index(openProfile);
  if(cards.length > (currentCardIndex + 1)) {
    cards.get(currentCardIndex + 1).click();
    setTimeout(function() {
        $("#profileDetail").modal("show");
    },500);
  } else {
    alert("You are on the last card!");
  }
});

不客气。您可以接受我的回答,以表明您已经找到了所需的解决方案。看到这一点:接受,还有一个疑问,我如何才能添加配置文件的标题作为下一个和上一个按钮,您可以这样做。在
配置文件卡的单击处理程序中
需要确定是否存在下一张/上一张卡。使用
$(this.find('.profile name').text()
)查找标题,并使用类似
$('.prev').text('new_label')
的内容在下一个/prev按钮上设置标签。欢迎使用。您可以接受我的回答,以表明您已经找到了所需的解决方案。看到这一点:接受,还有一个疑问,我如何才能添加配置文件的标题作为下一个和上一个按钮,您可以这样做。在
配置文件卡的单击处理程序中
需要确定是否存在下一张/上一张卡。使用
$(this.find('.profile name').text()
)查找标题,并使用类似
$('.prev').text('new_label')的内容在下一个/prev按钮上设置标签。