jquery-mobilelinked-listpiracy-prevention

How to prevent the default behavior on internal linked pages in jQueryMobile?


How can I prevent the default behavior on internal linked pages?

My goal is to prevent the user from accessing page contents without first authenticate.


Solution

  • Recently I was facing the same situation. I was using jQuery Mobile along with jQuery Templates, all sensitive data coming from a web service.

    My solution was to register a callback with the pagebeforeshow event for any page that the user needs authorization for. Within this callback function, I checked if the user is authorized, in my case this is a JSONP web service call, which either returns the data, or an appropriate error code.

    Then, if the user is authorized, the data is rendered with jQuery Templates; otherwise I redirect the user to a login page, using $.mobile.changePage().