Reputation: 4259
I'm using kendo Tabstrips and i am faceing an issue with loading the tabs
Html.Kendo().TabStrip().Name("TabStrip")
//.Animation(e=> e.Open(open => open.Fade(FadeDirection.In)))
//.Events(e => e.Select("OnSelect")
//.ContentLoad("ContentTabStripLoad")
//.Activate("Tabstrip_select")
//)
.Items(parent =>
{
parent.Add().Text("Sales").Selected(true)
.LoadContentFrom("_SalesItems", "DataTile", new { isEditingState = @Model.IsEditingState, dataSetID = @Model.DataSet.ID });
if (Model.EnableMixes == true)
{
parent.Add()
.Text("Sales of structural mixes")
//.Enabled(@Model.EnableMixes)
.LoadContentFrom("_SalesOfMixesItems", "DataTile", new { isEditingState = @Model.IsEditingState, dataSetID = @Model.DataSet.ID });
//.Selected(@Model.TabNameToSelect == "Sales of structural mixes" ? true : false);
}
parent.Add()
.Text("Customer/market costs")
.Enabled(@Model.EnableCommercialCosts)
.LoadContentFrom("_CustomerCosts", "DataTile", new { isEditingState = @Model.IsEditingState, dataSetID = @Model.DataSet.ID });
//.Selected(@Model.TabNameToSelect == "Customer/market costs" ? true : false);
if (Model.EnableMixes == true)
{
parent.Add()
.Text("Product mixes")
.Enabled(@Model.EnableMixes)
.LoadContentFrom("_ProductMixProducts", "DataTile", new { isEditingState = @Model.IsEditingState, dataSetID = @Model.DataSet.ID });
//.Selected(@Model.TabNameToSelect == "Product mixes" ? true : false);
}
if (Model.EnableCustomDriverItems == true)
{
parent.Add()
.Text("Custom driver items")
.Enabled(@Model.EnableCustomDriverItems)
.LoadContentFrom("_CustomDriverItems", "DataTile", new { isEditingState = @Model.IsEditingState, dataSetID = @Model.DataSet.ID });
//.Selected(@Model.TabNameToSelect == "Custom driver items" ? true : false);
}
})
.Render();
i have used select option to select default tab and its work fine and then if i click on other tab then the underlying action is being fired twice i am not able to prevent it and i donno why its being called twice . I have written the below lines to stop it from firing 2nd time but no use. On clicking the tab the corresponsing action is being called and then i'm hitting debugger into the below code and the action is being called again.
tabStrip.tabGroup.on('click', 'li', function (e) {
debugger;
return false;
});
Is there any work around for this
Upvotes: 0
Views: 1225
Reputation: 124
I have had this happen before, and it was because I was creating additional copies of the entire tabstrip in a function that was handling the clicks of certain tabs. Each time the click handler ran, a new copy would be created, which would correspond to how many times the action would be called the first time any unloaded tab was clicked.
Oops, bad code:
var tabStrip = $('#tabstripTemplate').kendoTabStrip().data("kendoTabStrip");
Fixed, just get reference to existing tabstrip:
var tabStrip = $('#tabstripTemplate').data("kendoTabStrip");
Upvotes: 1