views:

1461

answers:

1

After updating or creating a record I use url helper to redirect to the part on the page where the record happened to be located:

if record.save
  ....
  redirect_to records_url, :anchor => "record_" + record_id.to_s
end

the resulting url will be something like

http://localhost:3000/records#record_343242

I want to highlight the record using jquery or prototype, and the anchor is the exact id that I am looking for. Can I capture it?

+1  A: 

I presume you're trying to capture it in JavaScript?

var record_id = window.location.href.hash.split("_")[1];

In Prototype you could write:

var record_id = window.location.href.hash.split("_").last;
Dave Nolan