te')); return $arr; } /* 遍历用户所有主题 * @param $uid 用户ID * @param int $page 页数 * @param int $pagesize 每页记录条数 * @param bool $desc 排序方式 TRUE降序 FALSE升序 * @param string $key 返回的数组用那一列的值作为 key * @param array $col 查询哪些列 */ function thread_tid_find_by_uid($uid, $page = 1, $pagesize = 1000, $desc = TRUE, $key = 'tid', $col = array()) { if (empty($uid)) return array(); $orderby = TRUE == $desc ? -1 : 1; $arr = thread_tid__find($cond = array('uid' => $uid), array('tid' => $orderby), $page, $pagesize, $key, $col); return $arr; } // 遍历栏目下tid 支持数组 $fid = array(1,2,3) function thread_tid_find_by_fid($fid, $page = 1, $pagesize = 1000, $desc = TRUE) { if (empty($fid)) return array(); $orderby = TRUE == $desc ? -1 : 1; $arr = thread_tid__find($cond = array('fid' => $fid), array('tid' => $orderby), $page, $pagesize, 'tid', array('tid', 'verify_date')); return $arr; } function thread_tid_delete($tid) { if (empty($tid)) return FALSE; $r = thread_tid__delete(array('tid' => $tid)); return $r; } function thread_tid_count() { $n = thread_tid__count(); return $n; } // 统计用户主题数 大数量下严谨使用非主键统计 function thread_uid_count($uid) { $n = thread_tid__count(array('uid' => $uid)); return $n; } // 统计栏目主题数 大数量下严谨使用非主键统计 function thread_fid_count($fid) { $n = thread_tid__count(array('fid' => $fid)); return $n; } ?>javascript - Bootstrap 3 Default to first tab - Stack Overflow
最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Bootstrap 3 Default to first tab - Stack Overflow

programmeradmin4浏览0评论

I have a dynamic modal with two tabs. I want #tab1 to always be the default tab when someone opens the modal. The problem is if I open the modal and click on #tab2 then close, when I open the modal it is still on #tab2.

JSFiddle: /

I'm not sure how do it. I've tried setting the tab back to #tab1 when I see the .on('hidden.bs.modal' event but that doesn't seem to work.

Any help would be appreciated.

I have a dynamic modal with two tabs. I want #tab1 to always be the default tab when someone opens the modal. The problem is if I open the modal and click on #tab2 then close, when I open the modal it is still on #tab2.

JSFiddle: http://jsfiddle/9zo9hka4/

I'm not sure how do it. I've tried setting the tab back to #tab1 when I see the .on('hidden.bs.modal' event but that doesn't seem to work.

Any help would be appreciated.

Share Improve this question edited Mar 18, 2015 at 21:55 amphetamachine 30.6k12 gold badges67 silver badges74 bronze badges asked Jan 8, 2015 at 15:31 ntalektntalekt 8521 gold badge12 silver badges35 bronze badges
Add a ment  | 

4 Answers 4

Reset to default 9

From the Bootstrap docs you can activate the first tab like this:

$('#myTab a:first').tab('show')

So just add that to your modal when it's closed like this:

$('#clusterprofileanomalies').on('hidden.bs.modal', function () {
    //Add this line:
    $('.nav-tabs a:first').tab('show');

    //Snipped other non-relevant code
});

Update of your fiddle: http://jsfiddle/sesu6rkn/1/

I've encountered this before and if I recall I had to remove the class="active" from both tab and tabContent.

This might help: https://stackoverflow./a/11762931/1214858

i used this works fine i guess

$('.nav-tabs > li:first-child > a')[0].click();

The accepted answer didn't work for me, so I found this as solution for the problem. I just trigger a click event on the first link:

$('.nav-tabs a:first').click();
发布评论

评论列表(0)

  1. 暂无评论