Hello -
This question pertains to the usage of the destroy() method of kendo mobile view object. We have an application that starts off displaying a login screen (login-view), where a user enters username/password to view a "dashboard" screen (dashboard-view). Here is the index.html markup showing the login-view and the dashboard-view - for brevity's sake I am only showing the relevant portions of the code, and oversimplifying it.
The app is initialized as:
In the data-init methods of both views, we insert content into the respective content divs ("login-view-content" and "dashboard-view-content"). When the user logs out, the app navigates to the login-view. The problem we are facing is when a second (different) user logs in, the first user's content is still displaying. (Note that the data-init methods are not called for the second user since those views have already been inititalized. We tried solving this problem by destroying the dashboard view and emptying out the contents at the time of logging out:
On the second login, we recreated the view as:
We were expecting this to fire the dashboard-init event where we could insert the second user's content, but that wasn't the case - dashboard-init never gets called again. It seems intuitive that when a view is destroyed and recreated, then the corresponding data-init should be called. Is there a mechanism in the kendo.mobile's API that could address this problem. If not, what approach should be taken in this situation as recommended by Kendo's best practices?
Regards,
Sundar
This question pertains to the usage of the destroy() method of kendo mobile view object. We have an application that starts off displaying a login screen (login-view), where a user enters username/password to view a "dashboard" screen (dashboard-view). Here is the index.html markup showing the login-view and the dashboard-view - for brevity's sake I am only showing the relevant portions of the code, and oversimplifying it.
...
...
<
div
data-role
=
"view"
id
=
"login-view"
data-layout
=
"login-layout"
data-init
=
"login-init"
>
<
div
id
=
"login-view-content"
data-role
=
"content"
></
div
>
</
div
>
<
div
data-role
=
"view"
id
=
"dashboard-view"
data-layout
=
"default-layout"
data-init
=
"dashboard-init"
>
<
div
id
=
"dashboard-view-content"
data-role
=
"content"
></
div
>
</
div
>
...
...
this
.kendoApp =
new
kendo.mobile.Application(document.body, { initial:
"login-view"
});
$(
"#dashboard-view"
).data(
"kendoMobileView"
).destroy()
$(
"#dashboard-view-content"
).empty();
// also tried without this line.
$(
"#dashboard-view"
).kendoMobileView();
Regards,
Sundar