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

View 'beforeShow' event example

3 Answers 215 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Puño de la estrella del Norte
Top achievements
Rank 1
Puño de la estrella del Norte asked on 26 Jul 2012, 03:45 PM
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!

3 Answers, 1 is accepted

Sort by
0
Petyo
Telerik team
answered on 30 Jul 2012, 08:05 AM
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!
0
Puño de la estrella del Norte
Top achievements
Rank 1
answered on 30 Jul 2012, 11:14 AM
Petyo,

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

Thanks,
Brian
0
Puño de la estrella del Norte
Top achievements
Rank 1
answered on 25 Sep 2012, 02:52 PM
I never replied to this thread, but the example given worked like a champ.

Thanks again,
Brian
Tags
General Discussions
Asked by
Puño de la estrella del Norte
Top achievements
Rank 1
Answers by
Petyo
Telerik team
Puño de la estrella del Norte
Top achievements
Rank 1
Share this question
or