[web2py] Re: How to make address bar to correspond to the _next link redirection? /user/login still shows after login
It's best to handle on the client side if you can. The easiest is an IE conditional comment: !--[if IE] put some JS here that makes changes for IE -- it will be run only in IE browsers ![endif]-- You can also check via jQuery: if (jQuery.browser.msie) {do something} Finally, if you need to do something completely different on the server side, you can check for IE from within your web2py code via: if request.user_agent().browser.name == 'Microsoft Internet Explorer': Anthony On Sunday, December 4, 2011 10:55:56 PM UTC-5, Constantine Vasil wrote: For the record - this was only an issue for IE desktop. I had to switch off ajax in jQuery and now it works. That means I have to make two different templates - one for IE, and one for everything else. Does web2py has a function to recognize if the browser is any IE browser?
[web2py] Re: How to make address bar to correspond to the _next link redirection? /user/login still shows after login
That is great! Thank you both! I want to share my research about web2py + jQuery Mobile - made a lot of tests. The bottom line id as follows. JQuery Mobile is designed for mobile but it turns out it works on desktop too. This is great because one design can work for both mobile and desktop and it saves a lot of time. Unfortunately IE is creating an issues. 1) If ajax is enabled in jQuery Mobile the site looks great and the buttons look beautiful and have an added visible which makes clicking on buttons in IE to work always as expected, also submit buttons are working fine. The issue (only with IE) is that when ajax is enabled a hash appears in the browser bar and other side effects too. One side effect is for example you login on the site and you are on /user/login page and the address bar shows it up correctly. When you login redirection goes to front page but in the browser address bar /user/login stays. If you click on a link web2py changes the address bar correctly. But if you want to do a redirection, in address bar you see /user/login staying. You are in /myinfo but you see /user/login in the address bar. If yo uhappen to come to myinfo with clicking on other links before, IE adds '#' tag for example /user/login#myinfo. Coming to myinfo, you fill out the form and hit submit. Because in the browser bar you have /user/login#myinfo, the form is not submitted because web2py thinks you are in /user/login. 2) if ajax is enabled gobally jQuery Mobile has an option to add 'ajax disabled' for the link or submit button, but it does not change the behavior with IE. 3) the only way to show the browser bar correctly and eliminate the hash is by disabling the ajax globally. Which makes the site not looking good and now you have a different issue. Clicking on buttons and submit with IE is not reliable, you have to click on the upper part of the button (?!?). So the bottom line is for IE better to leave ajax on and solve the browser bar some other means. For example I mentioned that if a click is made manually the browser bar comes correct and there is not a hash. jQuery Mobile can make clicks programmatically and I will try to detect IE, get the web link of the current page (send via {{=link}} for example using web2py) and click to it programmatically. This will refresh the page and I believe the address bar wil lbe corrected. I don't see any other way. Regards, --Constantine
[web2py] Re: How to make address bar to correspond to the _next link redirection? /user/login still shows after login
I got response form jQuery Mobile developers and the answer is: The redirect issue isn't solvable until XmlHttpRequest2 see's better support and a redirect callback is added upstream in jQuery Core. If you are doing redirects on submission turning off ajax is really your only option. Now - how to implement an XmlHttpRequest2 redirect callback?
[web2py] Re: How to make address bar to correspond to the _next link redirection? /user/login still shows after login
Maybe instead of a regular redirect, send back a regular 200 response with the Ajax request, and add a special response header with the redirect URL (e.g., response.headers['client_redirect'] = URL('other_function')). On the client side, have some JS code that runs upon successful Ajax completion and looks for that header, and takes the appropriate action in that case. Anthony On Monday, December 5, 2011 4:33:31 PM UTC-5, Constantine Vasil wrote: I got response form jQuery Mobile developers and the answer is: The redirect issue isn't solvable until XmlHttpRequest2 see's better support and a redirect callback is added upstream in jQuery Core. If you are doing redirects on submission turning off ajax is really your only option. Now - how to implement an XmlHttpRequest2 redirect callback?
[web2py] Re: How to make address bar to correspond to the _next link redirection? /user/login still shows after login
Do you think this simple solution will work? http://www.adequatelygood.com/2010/7/Saner-HTML5-History-Management
[web2py] Re: How to make address bar to correspond to the _next link redirection? /user/login still shows after login
Don't know -- give it a try. On Monday, December 5, 2011 5:48:01 PM UTC-5, Constantine Vasil wrote: Do you think this simple solution will work? http://www.adequatelygood.com/2010/7/Saner-HTML5-History-Management
[web2py] Re: How to make address bar to correspond to the _next link redirection? /user/login still shows after login
Your approach is better. On the client side, have some JS code that runs upon successful Ajax completion and looks for that header. How you would do that?
[web2py] Re: How to make address bar to correspond to the _next link redirection? /user/login still shows after login
By the way I discovered jsbin - an easy way to publish html code, then got the source from browser bar just before it is rendered: http://jsbin.com/ojamak/4/edit here is where I hit submit: input data-ajax=false data-theme=e type=submit value=Sign Up / and I see: input name=_next type=hidden value=/default/myinfo / So if the page showing up after redirect is 'myinfo' (correct) but the browser bar is still '/user/register' (incorrect), wouldn't be easier if myinfo controller has the capability to change back the browser bar to the right one: '/user/register'?
[web2py] Re: How to make address bar to correspond to the _next link redirection? /user/login still shows after login
You could use the jQuery ajaxSuccess event handler (http://api.jquery.com/ajaxSuccess/), and in the ajaxSuccess event handler, check for the special header via xhr.getResponseHeader('name-of-header'). From there, you'll have to figure out what to do, based on how jQuery Mobile works (I'm not really familiar with it). Anthony On Monday, December 5, 2011 6:31:52 PM UTC-5, Constantine Vasil wrote: Your approach is better. On the client side, have some JS code that runs upon successful Ajax completion and looks for that header. How you would do that?
[web2py] Re: How to make address bar to correspond to the _next link redirection? /user/login still shows after login
Thank you, Anthony, will check it.
[web2py] Re: How to make address bar to correspond to the _next link redirection? /user/login still shows after login
The login is here: /user/login auth.settings.login_next = URL('default', args='index') I expect the address bar after redirection to show in routes.py routers = dict( BASE = dict( default_application = 'my_dev', default_controller='default' ), ) routes_in = ( ('/default/user/$anything', '/my_dev/default/user/$anything'), ('/$c/$f', '/my_dev/$c/$f'), ('/favicon.ico', '/my_dev/static/favicon.ico'), ('/robots.txt', '/my_dev/static/robots.txt'), ) routes_out = ( ('/my_dev/default/user/$anything', '/default/user/$anything'), ('/my_dev/$c/$f', '/$c/$f'), ('/static/$anything', '/my_dev/static/$anything'), )
[web2py] Re: How to make address bar to correspond to the _next link redirection? /user/login still shows after login
Not sure it has anything to do with your problem, but you cannot mix the parameter based and pattern based rewrite systems -- if you're using routers, you cannot also use routes_in/routes_out (I think the presences of routers will cause routes_in/routes_out to be ignored). Regarding the address bar issue, it sounds like a jQuery Mobile issue -- you'll have to figure out how to get it to deal with your URLs appropriately. web2py is sending standard http responses to whatever URL requests it is receiving. Anthony On Sunday, December 4, 2011 3:58:48 AM UTC-5, Constantine Vasil wrote: The login is here: /user/login auth.settings.login_next = URL('default', args='index') I expect the address bar after redirection to show in routes.py routers = dict( BASE = dict( default_application = 'my_dev', default_controller='default' ), ) routes_in = ( ('/default/user/$anything', '/my_dev/default/user/$anything'), ('/$c/$f', '/my_dev/$c/$f'), ('/favicon.ico', '/my_dev/static/favicon.ico'), ('/robots.txt', '/my_dev/static/robots.txt'), ) routes_out = ( ('/my_dev/default/user/$anything', '/default/user/$anything'), ('/my_dev/$c/$f', '/$c/$f'), ('/static/$anything', '/my_dev/static/$anything'), )
[web2py] Re: How to make address bar to correspond to the _next link redirection? /user/login still shows after login
Note, you might consider asking about this in the jQuery Mobile forum: http://forum.jquery.com/jquery-mobile On Sunday, December 4, 2011 8:42:34 AM UTC-5, Anthony wrote: Not sure it has anything to do with your problem, but you cannot mix the parameter based and pattern based rewrite systems -- if you're using routers, you cannot also use routes_in/routes_out (I think the presences of routers will cause routes_in/routes_out to be ignored). Regarding the address bar issue, it sounds like a jQuery Mobile issue -- you'll have to figure out how to get it to deal with your URLs appropriately. web2py is sending standard http responses to whatever URL requests it is receiving. Anthony On Sunday, December 4, 2011 3:58:48 AM UTC-5, Constantine Vasil wrote: The login is here: /user/login auth.settings.login_next = URL('default', args='index') I expect the address bar after redirection to show in routes.py routers = dict( BASE = dict( default_application = 'my_dev', default_controller='default' ), ) routes_in = ( ('/default/user/$anything', '/my_dev/default/user/$anything'), ('/$c/$f', '/my_dev/$c/$f'), ('/favicon.ico', '/my_dev/static/favicon.ico'), ('/robots.txt', '/my_dev/static/robots.txt'), ) routes_out = ( ('/my_dev/default/user/$anything', '/default/user/$anything'), ('/my_dev/$c/$f', '/$c/$f'), ('/static/$anything', '/my_dev/static/$anything'), )
[web2py] Re: How to make address bar to correspond to the _next link redirection? /user/login still shows after login
I understand that now about not mixing routing. OK I am using routes.example.py default_application = 'my_app'# ordinarily set in base routes.py default_controller = 'default' # ordinarily set in app-specific routes.py default_function = 'index' # ordinarily set in app-specific routes.py routes_app = ((r'/(?Pappwelcome|admin|app)\b.*', r'\gapp'), (r'(.*)', r'my_app'), (r'/?(.*)', r'my_app')) I see I can get rid of the my_app but how to get rid from default? and when addressing the new rules what URL I have to use URL('default','user') or URL('user')? {{try:}}{{=current.app.auth.navbar(action=URL('default','user'))}}{{except:pass}}
[web2py] Re: How to make address bar to correspond to the _next link redirection? /user/login still shows after login
For the record - this was only an issue for IE desktop. I had to switch off ajax in jQuery and now it works. That means I have to make two different templates - one for IE, and one for everything else. Does web2py has a function to recognize if the browser is any IE browser?
Re: [web2py] Re: How to make address bar to correspond to the _next link redirection? /user/login still shows after login
On 5 December 2011 05:55, Constantine Vasil thst...@gmail.com wrote: For the record - this was only an issue for IE desktop. I had to switch off ajax in jQuery and now it works. That means I have to make two different templates - one for IE, and one for everything else. Does web2py has a function to recognize if the browser is any IE browser? I you look in layout.html of the welcome app near the top you will see that provision is made for detecting IE and acting on it. You can add your code there for the alternatives.: Regards Johann -- Because experiencing your loyal love is better than life itself, my lips will praise you. (Psalm 63:3)
[web2py] Re: How to make address bar to correspond to the _next link redirection? /user/login still shows after login
The address bar shows /user/login#/user/login I am using 1.99.3 dev version and cannot reproduce this behavior When i do login the resulting page shows the address without parameters and hitting the back button shows the old address. Have you customized the scaffolding app? Could you post relevant app code?
[web2py] Re: How to make address bar to correspond to the _next link redirection? /user/login still shows after login
never seen this either. On Dec 3, 8:29 am, Alan Etkin spame...@gmail.com wrote: The address bar shows /user/login#/user/login I am using 1.99.3 dev version and cannot reproduce this behavior When i do login the resulting page shows the address without parameters and hitting the back button shows the old address. Have you customized the scaffolding app? Could you post relevant app code?
[web2py] Re: How to make address bar to correspond to the _next link redirection? /user/login still shows after login
I am using JQuery Mobile which is adding these hashes '#' after clicking on a link or Submit button. Cannot get rid of them no matter what. Also switched off ajax on the links.