【发布时间】:2011-11-23 23:17:54
【问题描述】:
以下输出是通过Haml 布局文件和index.haml 从Sinatra 中生成的
<!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 替换为对root /' but if it is an AJAX call, my code at/checks for it and theoretically should only replace what's inbody 的调用,但它会替换整个文档。
这是我的 Sinatra 和 Haml Ruby 代码
get '/' do
... set some instance vars to be displayed in index.haml ...
haml :index, :layout => (request.xhr? ? false : :layout)
end
【问题讨论】: