[英]JavaScript pass data on Bootstrap navtab click
I am working on an application that loads a form inside of a bootstrap navtab. 我正在开发一个在引导navtab内加载表单的应用程序。 I have a datepicker that allows the user to enter a date click submit and update the data in the navtab.
我有一个日期选择器,允许用户输入一个日期,单击“提交”并更新navtab中的数据。 What I want to do is allow the user to select a date, and then when a tab is clicked it will use that date to display the data.
我想做的是允许用户选择一个日期,然后单击一个选项卡时,它将使用该日期来显示数据。 As it is now, it will only work if the submit button is clicked.
与现在一样,仅在单击“提交”按钮时它将起作用。 I know I need to change the code in my navtabs to match what I do when the button is clicked, but I'm not sure how to do it.
我知道我需要更改导航栏中的代码以匹配单击按钮时的操作,但是我不确定该怎么做。 Here is my navtabs:
这是我的导航表:
<ul class="nav nav-tabs spiff_tabs" role="tablist">
<li role="presentation" class="active">
<a href="#home" aria-controls="home" role="tab" data-id="delayedspiff" data-toggle="tab" onclick="FormGet('dashboard/delayedspiff', 'delayedspiff')">Potential Spiff</a>
</li>
<li role="presentation">
<a href="#profile" aria-controls="profile" role="tab" data-id="instantspiff" data-toggle="tab" onclick="FormGet('dashboard/instantspiff', 'delayedspiff')">Instant Spiff</a>
</li>
</ul>
<!-- Tab panes -->
<div class="tab-content" id="details">
<div role="tabpanel" class="tab-pane active" id="delayedspiff"></div>
<div role="tabpanel" class="tab-pane" id="instantspiff"></div>
</div>
</div>
</div>
</div>
Here is the button click JavaScript: 这是单击JavaScript的按钮:
<script>
$(".spiffdate-btn").click(function(){
var correctId = $("ul.spiff_tabs li.active a").attr('data-id');
var endDate = $("#startDate").val();
if (endDate == "") {
} else {
if (correctId == "delayedspiff")
{
FormGet('dashboard/delayedspiff?endDate=' + endDate, 'delayedspiff')
} else if (correctId = "instantspiff") {
FormGet('dashboard/instantspiff?endDate=' + endDate, 'delayedspiff')
}
}
});
</script>
How do I change the navtab Formget function to match that of the button clicks formget function? 如何更改navtab Formget函数以使其与单击按钮的formget函数相匹配?
Apply the spiffdate-btn class to your tab links so that they will also trigger the same function as your submit button without the onclick attribute. 将spiffdate-btn类应用于选项卡链接,以便它们也将触发与您的提交按钮(没有onclick属性)相同的功能。 You could use a random css class that is more generically named and doesn't apply css to your elements.
您可以使用更通用的随机CSS类,并且不将CSS应用于您的元素。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.