2012年5月4日星期五

jQuery Mobile default use Ajax load link and form

jQuery Mobile default use Ajax load link and form

背景:  Cakephp 用 AuthComponent allow 去分別要唔要 login 睇
public function beforeFilter() {
    parent::beforeFilter();
    $this->Auth->allow('display');
}
係正常 browser 睇要 login 既 page 會302 redirect 左去 login page

但係加左jQuery Mobile 就唔 work...


扮 mobile 測試
因為係用 mobile debug 唔到

所以係 Firefox 安 user agent switcher

最後知道
Cakephp AuthComponent 會對 Ajax call 又 handle 唔到既request 出 403
解決方法有:
1.
係 html code disable Ajax call

<form data-ajax="false" action="?" method="post" >

2.
日本人改左 AuthComponent 去 solve

http://www.hideblog.net/nikkis/show/222/

3.
成個 jQuery Mobile disable Ajax load link
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.0-rc.1/jquery.mobile-1.1.0-rc.1.min.css" />
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script language="javascript" type="text/javascript">
    $(document).bind("mobileinit", function () {
        $.mobile.ajaxEnabled = false;
    });
</script>
<script src="http://code.jquery.com/mobile/1.1.0-rc.1/jquery.mobile-1.1.0-rc.1.min.js"></script>
from
http://jquerymobile.com/demos/1.0a4/docs/api/globalconfig.html


yeah, it just works~~

Comments:

blog comments powered by Disqus
Related Posts with Thumbnails