将Bootstrap选项卡链接到服务器URL
看起来已经有很多讨论,但我无法让我的代码工作。
我有一个Django项目和带有Bootstrap tab药片的模板。 我试图将标签菜单药片绑定到我的Django项目的url。 我只是无法读取Uncaught Error: Syntax error, unrecognized expression: /employee_user_info/40/
客户端错误。 这是我的代码:
HTML:
{{person_details_form.second_nm_rus.value}} {{person_details_form.first_nm_rus.value}} {{person_details_form.middle_nm_rus.value}}
Django urlconf
url(r'^employee_user_info/(?P\d+)/$',employee_views.profile_user_info, name ='employee_user_info'),
JS
var navpills = $('.nav-pills'); $(function () { // activate tab on click navpills.on('click', 'a', function (e) { var $this = $(this); // prevent the Default behavior e.preventDefault(); // send the hash to the address bar window.location.hash = $this.attr('href'); // activate the clicked tab $this.tab('show'); // The error arises here }); $(window).bind('hashchange', refreshHash); // read has from address bar and show it if(window.location.hash) { // show tab on load refreshHash(); } }); function refreshHash() { navpills.find('a[href="'+window.location.hash+'"]').tab('show'); }
更新:
单击Tab 2时,客户端发生错误。
更新2
当按Tab 2时,url变为http://127.0.0.1:8000/employee_profile_main/40/#/employee_user_info/40/
我想,降压停在这里
你不能用/
设置href
。 我猜它用作选择器。