Looking to populate a view based on part of a URL.
http://www.example.com/f/objectID
I have a website with a view that loads based on the an objectID that is stored on parse.com
how can I extract/interpret “objectID” from the url to populate the /f/ view?
Take a look at the
window.locationobject. From there you just need some string methods..split()will split the path into the fragments separated by/and.pop()will retrieve the last one. Of course, ifobjectIDmay not always be the last segment, use the proper (0-based) index to retrieve it from array returned bysplit.Another solution that may have better performance (shouldn’t really make a difference for this use case), assumes that
objectIDis the last segment:Fiddle