开发者

Adding New Tab with JQuery UI tabs

I am developing a web application using MVC .net framework. 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. 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 开发者_Python百科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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜