gi do

Hi,

I use the load on demand with my tab.

@{Html.EJ().Tab("Tab4").Items(data =>
{
    data.Add().ID("tabitem1").Text("ASP.NET").ContentTemplate(@<div></div>);
      data.Add().ID("tabitem2").Text("JavaScript").ContentTemplate(@<div></div>);

    }).ClientSideEvents(e =>
    {
        e.ItemActive("onClientActive");
     }).Render();
 }

<script>
    var flag;
    var flag1;
    function onClientActive(e) {
        if (e.model.selectedItemIndex == 0 && ej.isNullOrUndefined(flag)) {
            $.ajax({
                url: '/Tab/_Chart',
                type: 'POST'

            }).done(function (result) {
                $("#tabitem1").html(result);

            })
            flag = true;

        }
        if (e.model.selectedItemIndex == 1 && ej.isNullOrUndefined(flag1)) {
            $.ajax({
                url: '/Tab/_Grid',
                type: 'POST'


            }).done(function (result) {
                $("#tabitem2").html(result);

            })
            flag1 = true;
        }
    }
</script>

I would like tab 1 to be pre-loaded when creating the page.

3 Replies

PO Prince Oliver Syncfusion Team October 31, 2017 06:36 AM UTC

Hi Arnaud, 

Thank you for contacting Syncfusion forums. 

To pre-loaded tab 1 when creating the page, you need to call the “onClientActive” method in the create event. Kindly refer to the following code snippet. 

@{Html.EJ().Tab("Tab4").Items(data => 
    { 
    data.Add().ID("tabitem1").Text("ASP.NET").ContentTemplate(@<div></div>); 
    data.Add().ID("tabitem2").Text("JavaScript").ContentTemplate(@<div></div>); 
 
    }).ClientSideEvents(e => 
    { 
        e.ItemActive("onClientActive").Create("onClientActive"); 
    }).Render(); 
} 

We have prepared a sample for your reference, kindly refer to the following link for the sample: https://www.syncfusion.com/downloads/support/forum/133470/ze/TabLoadOnDemand-1449018739 

Regards, 
Prince 



AB Arnaud--Mozdzer Bastien October 31, 2017 08:41 AM UTC

Thank you for your answer, it works !



PO Prince Oliver Syncfusion Team October 31, 2017 09:36 AM UTC

Hi Arnaud, 

Most welcome. We are glad to know that your issue is resolved. 

Regards, 
Prince 


Loader.
Up arrow icon