記一次 jquery mobile被AJAX坑了。

來源:互聯網
上載者:User

標籤:style   blog   http   color   io   for   ar   cti   

簡單情況是 MVC 重新導向,URL不變

試了N種方式,跳來跳去,無解,服務端跳,寫JS跳,產生跳轉中間頁跳。失敗

後來一看,明明已經跳到新頁了,樣式什麼還是原頁的,有點火大了。

 

出去溜一圈,喝杯水,和同事東拉西扯一通。

回頭一看,突然反應過來,這不是AJAX的效果麼,坑我半個多小時。

 

為加驗證,是手動調用的submit。沒往AJAX上想。

$("form").submit();

 

但jquery mobile 內部會把submit也通過AJAX訪問。

 

解決辦法是禁用。 注意 

綁定mobileinit方法要寫在 引入jquerymobile之前。
<script src="http://code.jquery.com/jquery-1.8.3.min.js"></script><script>$(document).bind("mobileinit", function () {$.mobile.ajaxEnabled = false;$.mobile.defaultPageTransition = ‘none‘;$.mobile.hashListeningEnabled = true;$.mobile.pageLoadErrorMessage = ‘Sorry, something went wrong. Please try again.‘;$.mobile.buttonMarkup.hoverDelay = false;});</script><script src="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.js"></script>

 教訓

每接觸新東西之前都要粗略把文檔看一遍,再看幾本書的。

最近業餘時間忙補番了,大意了,被其所坑。

好久沒被坑過了……

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.