简体   繁体   English

使用JQuery UI选项卡添加新选项卡

[英]Adding New Tab with JQuery UI tabs

I am developing a web application using MVC .net framework. 我正在使用MVC .net框架开发Web应用程序。 In the user interface of this application i want to create a tab when a button is clicked. 在此应用程序的用户界面中,我想在单击按钮时创建一个选项卡。 following is the method i am creating this tab when a button is clicked in the user interface 以下是在用户界面中单击按钮时我创建此选项卡的方法

$('#tabs').tabs("add", 'uploadnewcv', 'Add New CV');

while i creating this tab i want to add content in to this tab. 当我创建此选项卡时,我想在此选项卡中添加内容。 the post method retrieve data and that data is in the data variable. post方法检索数据,并且该数据位于data变量中。 i want to add that data in to the tab i created. 我想将该数据添加到我创建的选项卡中。 could some one having experience on this guide me how to add content in to tab while it is creating. 有人对此有经验可以指导我如何在创建标签时向其中添加内容。 thanks in advance for any help 预先感谢您的任何帮助

function addNewCV() {
        var text = 'xyz';

        $('#tabs').tabs("add", 'uploadnewcv', 'Add New CV');

        $.post("/AddNewCV/addnewcv", { name: text },
        function (data) {
            document.getElementById('uploadnewcv').innerHTML = data;
            //alert(document.getElementById('ui-tabs-3').innerText);
        });
    }

I think there's no all-in-one solution. 我认为没有一体化的解决方案。 But what you've done should work, doesn't it? 但是您所做的应该有效,不是吗?
You can optimize it a bit, like this: 您可以对其进行一些优化,如下所示:

function addNewCV() {
    var text = 'xyz';
    $.post(
        "/AddNewCV/addnewcv",
        { name: text },
        function (data) {
            $('#tabs').tabs("add", 'uploadnewcv', 'Add New CV');
            $('#uploadnewcv').html(data);
            //alert($('#ui-tabs-3').text());
        }
    );
}

So the tab is generated when the data are already there. 因此,当数据已经存在时将生成选项卡。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM