views:

42

answers:

1

Hi all,

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 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);
        });
    }
A: 

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.

elektronikLexikon