I've got 2 list views on my page...
<
div
id
=
"contents"
data-role
=
"view"
data-title
=
"Contents"
data-layout
=
"main-layout"
>
<
ul
id
=
"primaryMenu"
></
ul
>
<
ul
id
=
"subMenu"
></
ul
>
</
div
>
function
loadMenu()
{
var
primaryMenu =
new
kendo.data.DataSource({
transport: {
read: {
dataType:
"json"
}
}
});
primaryMenu.read();
$(
"#primaryMenu"
).kendoMobileListView({
template :
"<strong>#:data.MenuTitle#</strong>"
,
dataSource: primaryMenu,
click:
function
(e) {
loadSubMenu(e.dataItem.BookMenuID);
}
});
}
function
loadSubMenu(bookMenuID)
{
var
subMenu =
new
kendo.data.DataSource({
transport: {
read: {
dataType:
"json"
,
data: {BookMenuID : bookMenuID},
}
}
});
subMenu.read();
$(
"#subMenu"
).kendoMobileListView({
template :
"<i>#:data.MenuTitle#</i>"
,
dataSource: subMenu,
click:
function
(e) {
alert(e.dataItem.ChildCount);
if
(e.dataItem.ChildCount == 0)
{
loadContent(e.dataItem.BookMenuID);
app.navigate(
"#content"
);
}
}
});
}
function
loadContent(bookMenuID)
{
$.ajax({
dataType:
"json"
,
data: {
BookMenuID: bookMenuID
},
success:
function
(data, textStatus, jqXHR) {
$(
'#selectedContent'
).html(data.Content);
},
error:
function
(jqXHR, textStatus, errorThrown) {
alert(jqXHR +
', '
+ textStatus +
', '
+ errorThrown);
}
});
}
The 1st list view loads OK, and you can click on this as many times as you like and the 2nd list view always loads correctly.
However the click event of the 2nd list view only works the first time it is loaded, then each time it is refreshed by clicking on the 1st list view the 2nd list view click event stops working...
Do I need to put something in place to remove the 2nd list view and recreate it?