0
我在我的show.html.erb
从另一个脚本替换Rails中的脚本中的值
<script type="text/javascript">
$(document).ready(function(){
$("#map<%= shop.id %>").gMap({ markers: [{ latitude: <%= shop.lat %>,
longitude: <%= shop.lng %>,
html: "<%=h shop.name %><br/><a href='http://maps.google.com/maps?q=<%=h shop.address_geo %>' target='_blank'>See Full Map</a>" },
],
zoom: 16 });
</script>
中间有这个。然后在它的底部,我想做这样的事情:
function append_place(type) {
var shop_id = id;
$("shop_id").append(shop_id);
}
我希望用<%= shop.id %>
替换id
。我知道这两个脚本在编码时都是错误的,但我该如何实现呢?不能使用Rails cos这是客户端和JSON。它首先从数据库中提取id
,然后通过内联脚本附加它。
谢谢。
'var shop_id = $ .myPageVars.shop_id ||假;似乎打破所有的代码。 – Victor 2010-11-02 07:36:01