在更新或创建记录后,我使用url helper来重定向到页面上记录所在的部分:
if record.save
....
redirect_to records_url, :anchor => "record_" + record_id.to_s
end
生成的URL将类似于
http://localhost:3000/records#record_343242
我想使用jQuery或原型来突出显示记录,并且锚点是我要查找的确切ID。我能捕获它吗?
在更新或创建记录后,我使用url helper来重定向到页面上记录所在的部分:
if record.save
....
redirect_to records_url, :anchor => "record_" + record_id.to_s
end
生成的URL将类似于
http://localhost:3000/records#record_343242
我想使用jQuery或原型来突出显示记录,并且锚点是我要查找的确切ID。我能捕获它吗?
我猜你是想在JavaScript中捕获它吧?
var record_id = window.location.href.hash.split("_")[1];
var record_id = window.location.href.hash.split("_").last;