我有一個在瀏覽器中完美工作的Web應用程序 - 無論是在桌面還是移動設備上。 問題是當我嘗試漂亮起來加入:Rails iOS主屏幕Web應用程序 - 無法刪除記錄
<meta name="apple-mobile-web-app-capable" content="yes" />
這個偉大的工程太 - 多達我需要在應用程序中刪除記錄點。
我還使用這個偉大的要點,我發現 - https://gist.github.com/1042167停止應用程序轉換成移動Safari瀏覽器:
<script type="text/javascript">
(function(document,navigator,standalone) {
// prevents links from apps from oppening in mobile safari
// this javascript must be the first script in your <head>
if ((standalone in navigator) && navigator[standalone]) {
var curnode, location=document.location, stop=/^(a|html)$/i;
document.addEventListener('click', function(e) {
curnode=e.target;
while (!(stop).test(curnode.nodeName)) {
curnode=curnode.parentNode;
}
// Conditions to do this only on links to your own app
// if you want all links, use if('href' in curnode) instead.
if(
'href' in curnode && // is a link
(chref=curnode.href).replace(location.href,'').indexOf('#') && // is not an anchor
( !(/^[a-z\+\.\-]+:/i).test(chref) || // either does not have a proper scheme (relative links)
chref.indexOf(location.protocol+'//'+location.host)===0) // or is in the same protocol and domain
) {
e.preventDefault();
location.href = curnode.href;
}
},false);
}
})(document,window.navigator,'standalone');
</script>
我想知道如果這可以被改變,因此數據的方法=「刪除」,將打得好嗎?在那一刻 - 當我點擊「刪除」時 - 「你確定嗎?」確認框掛起一兩秒鐘,然後把我重新放回到同一個顯示頁面上,但沒有發生刪除...
感謝您的詳細回覆。我添加了插件,刪除了數據方法,添加了類並單擊處理程序,然後添加了您的函數。不知道我是否需要評論一些相沖突的東西?我可以導航應用程序,但刪除現在只是沒有生氣......我仍然想知道爲什麼在我現有的代碼 - 當它成爲一個iOS homescreened網絡應用程序時,我只會遇到問題。 – ritchielee
當handleDeleteLink()被調用時,表單是否被正確創建/提交?我從應用程序中抽象出了上面的代碼,因此我可能會在概括出來時犯了一個錯誤。你的網絡檢查員應該能夠告訴你事情正在破裂的地方 –