通过Haml
布局文件生成以下输出和index.haml
jQuery的身体负荷内Sinatra
与西纳特拉/ Haml的
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Meeting</title>
<meta content='width=device-width, initial-scale=1' name='viewport' />
<script src='http://code.jquery.com/jquery-1.6.4.min.js'></script>
<script src='http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.js'></script>
<link href='http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.css' rel='stylesheet' type='text/css' />
<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js'></script>
<script type='text/javascript'>
//<![CDATA[
$(document).ready(function() {
setTimeout(getUpdate,10000);
function getUpdate(){
$("body").load("/");
}
})
//]]>
</script>
</head>
<body>Some text</body>
</html>
我试图做到的是通过调用替换body
根/' but if it is an AJAX call, my code at
/checks for it and theoretically should only replace what's in
body`,但它取代了整个文档。
这里是我的Sinatra
& Haml
Ruby代码
get '/' do
... set some instance vars to be displayed in index.haml ...
haml :index, :layout => (request.xhr? ? false : :layout)
end
通过“替换整个文档”,我的意思是当调用jQuery方法时,上面的整个HTML输出被替换为'some text',没有'html','head',甚至是'script'代码。其实我没有设置jQuery Mobile'div's,所以它不是你描述的问题。 –
你使用什么浏览器?你是如何观察DOM变化的?通过Chrome元素检查器或Firebug?即使你没有设置jQuery Mobile div,它也会自动修改你的DOM结构,只要你加载jQuery的移动javascript。 – miaout17