View 'beforeShow' event example

4 posts, 0 answers
  1. Puño de la estrella del Norte
    Puño de la estrella del Norte avatar
    3 posts
    Member since:
    Jul 2012

    Posted 26 Jul 2012 Link to this post

    Hello,

    First off, thanks for putting together a great suite of controls. You've made my life as a mobile environment developer much easier! I do have a question though. I see in the release notes and in the documentation that the mobile View supports an event called "beforeShow".  Is there an example somewhere that utilizes that event? I'm trying to wire up some logic around the browser's back button and I'd like to use that event to determine if the user is logged in before displaying the requested view. When I try to attach a handler to the event like so:

    <div data-role="view" id="someView" data-show="showSomeView" data-beforeShow="viewBeforeShow">
    /* div content here */
    </div>


    The viewBeforeShow method never fires.  The showSomeView event works as expected, but the user is able to navigate back to that view even though they are no longer logged in to the app (exactly the case I'm trying to prevent). 

    Here is the code for viewBeforeShow:

    function viewBeforeShow(view) {
        if(loggedOut == true) {    // loggedOut is just a global variable for now
            window.kendoMobileApplication.navigate('#loginView');  // loginView is the login mobile view
        }
    }

    I don't know if this is the correct way to handle this scenario, but I can figure that out once I start handing the event.

    I should mention I'm using the trial version 2012.2.710 (just downloaded it today). I will eventually translate this to the licensed version for my employer, but I was trying a proof of concept before I worried about that.

    Is this the right way to configure the handler for this event? Any help would be greatly appreciated.

    Thanks again for the great work!
  2. Petyo
    Admin
    Petyo avatar
    2444 posts

    Posted 30 Jul 2012 Link to this post

    Hi Brian,

    The data attributes names use dashes instead of camel casing. In this case, this would result in data-before-show

    See this jsfiddle for example.

    Regards,
    Petyo
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. Puño de la estrella del Norte
    Puño de la estrella del Norte avatar
    3 posts
    Member since:
    Jul 2012

    Posted 30 Jul 2012 Link to this post

    Petyo,

    Thank you for the response, I'll give that a try. 

    Thanks,
    Brian
  4. Puño de la estrella del Norte
    Puño de la estrella del Norte avatar
    3 posts
    Member since:
    Jul 2012

    Posted 25 Sep 2012 Link to this post

    I never replied to this thread, but the example given worked like a champ.

    Thanks again,
    Brian
Back to Top