This is a migrated thread and some comments may be shown as answers.

Drawer Breaks if View Redirects

2 Answers 94 Views
Drawer (Mobile)
This is a migrated thread and some comments may be shown as answers.
Bill
Top achievements
Rank 1
Bill asked on 18 Jul 2013, 11:01 PM
If you have a view which does an app.navigate() when shown, the drawer breaks.  The drawer will show the previous view instead of the drawer on the view navigated to.

In my case, I had a login remote view which would simply do an app.navigate() to the home view if the user was already logged in.  I did this on data-before-show.  The issue is something with timing.  I ended up putting a setTimeout() on the app.navigate() to 1 second and then the navigation & drawer worked fine after.

@if (Request.IsAuthenticated)
{
    AppsWebAppContext context = (AppsWebAppContext)ViewBag.AppContext;
    string displayName = context.User.DisplayName;
    string avatarUrl = (context.User.HasAvatar) ? context.User.AvatarSmallUrl : Url.GetUrlRoot() + "/Images/NoAvatar/small.jpg";
     
    <div id="viewLogin" data-title="Login" data-role="view" data-before-show="viewLoginOnBeforeShow" data-hide="onHide">
        <script type="text/javascript">
            function viewLoginOnBeforeShow(e) {
                showLoading();
 
                onBeforeShow(e);
 
                $("#userAvatar").attr("src", "@avatarUrl");
                $("#userDisplayName").text("@displayName");
 
                setTimeout(function () { navigateHome(); hideLoading(); }, 1000);
            }
        </script>
    </div>
}

2 Answers, 1 is accepted

Sort by
0
Accepted
Kiril Nikolov
Telerik team
answered on 19 Jul 2013, 08:44 AM
Hi Bill,

When performing redirection using the beforeShow event of the Kendo UI Mobile Drawer, you need to prevent the event from happening using the event parameter and preventDefault() method and then redirect to the desired page.

Please check this documentation page for more information:

http://docs.kendoui.com/api/mobile/view#events-beforeShow

Regards,
Kiril Nikolov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Bill
Top achievements
Rank 1
answered on 19 Jul 2013, 12:44 PM
Kiril, that worked perfectly!  Thanks!
Tags
Drawer (Mobile)
Asked by
Bill
Top achievements
Rank 1
Answers by
Kiril Nikolov
Telerik team
Bill
Top achievements
Rank 1
Share this question
or