Drawer Breaks if View Redirects

3 posts, 1 answers
  1. Bill
    Bill avatar
    75 posts
    Member since:
    Feb 2013

    Posted 18 Jul 2013 Link to this post

    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. Answer
    Kiril Nikolov
    Admin
    Kiril Nikolov avatar
    2565 posts

    Posted 19 Jul 2013 Link to this post

    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!
  3. Kendo UI is VS 2017 Ready
  4. Bill
    Bill avatar
    75 posts
    Member since:
    Feb 2013

    Posted 19 Jul 2013 Link to this post

    Kiril, that worked perfectly!  Thanks!
Back to Top