The example below illustrates a case in which tabs do not select when the dataUrlField is specified as a page local href such as '#content1'.
It seems like this case should work since the select event fires and the correct element is passed in. It would be ideal if there was a more reliable way to obtain access to the data element to which a tab is bound.
It seems like this case should work since the select event fires and the correct element is passed in. It would be ideal if there was a more reliable way to obtain access to the data element to which a tab is bound.
<!DOCTYPE html>
<
html
xmlns
=
"http://www.w3.org/1999/xhtml"
>
<
head
>
<
link
href
=
"kendo.common.min.css"
rel
=
"stylesheet"
/>
<
link
href
=
"kendo.default.min.css"
rel
=
"stylesheet"
/>
<
script
src
=
"jquery.min.js"
></
script
>
<
script
src
=
"kendo.all.min.js"
></
script
>
<
script
>
$(function () {
var data = [{ Name: 'Tab 1', Url: '#content1' }, { Name: 'Tab 2', Url: '#content2' }];
$("#tabstrip").kendoTabStrip({
dataTextField: "Name",
dataUrlField: "Url",
dataSource: data,
select: function (el) {
//would be nice to have a reference to the data source data item here rather than relying on the item index.
var itemIndex = $(el.item).index();
$('.tabContent').hide();
$('#content' + itemIndex).show();
}
});
getSelectedTabIndex = function () {
return $("#tabstrip").data("kendoTabStrip").select().index();
}
$('#showSelectedTabIndex').click(function () {
//always returns -1
alert(getSelectedTabIndex());
});
});
</
script
>
</
head
>
<
body
>
1.) Click a tab <
br
/>
2.) Click the Show Selected Tab Index button.<
br
/>
<
br
/>
The tab is not visually selected and the value returned for the selected index is -1.
<
br
/><
br
/>
<
button
id
=
"showSelectedTabIndex"
>Show Selected Tab Index</
button
>
<
div
id
=
"tabstrip"
></
div
>
<
div
id
=
"content0"
class
=
"tabContent"
style
=
"display:none;"
>Content 1</
div
>
<
div
id
=
"content1"
class
=
"tabContent"
style
=
"display:none;"
>Content 2</
div
>
</
body
>
</
html
>