jquery - How to disable the default JQM page in a SPA? -
i have single page jqm application - jqm "pages" in 1 document:
<div> @renderpage("views/login.cshtml") @renderpage("views/page1.cshtml") @renderpage("views/page2.cshtml") </div> how can disable displaying jqm page default, happens login.cshtml, can manually invoke transition method erase login page history, after user has logged in ? eq want invoke manually on initial document load:
$.mobile.changepage('#login-page', { reverse: false, changehash: true }); alternatively, possible set "reverse" attribute false without changepage call?
if want can give client side solution.
basically use older example: http://jsfiddle.net/gajotres/3phkz/ prevent page transition if condition not fulfilled. , @ point can forward user @ other page changepage function.
this solution work in case because trigger during every page transition , if next page in case login page @ conditions , whatever want. can allow transition, prevent altogether or redirect page:
$(document).on('pagebeforechange', function(e, data){ var = data.topage, = data.options.frompage; if (typeof === 'string') { var u = $.mobile.path.parseurl(to); = u.hash || '#' + u.pathname.substring(1); if (from) = '#' + from.attr('id'); if (from === '#index' && === '#second') { alert('can not transition #index #second!'); e.preventdefault(); e.stoppropagation(); // remove active status on button, if transition triggered button $.mobile.activepage.find('.ui-btn-active').removeclass('ui-btn-active ui-focus ui-btn');; } } });
Comments
Post a Comment