Looking to populate a view based on part of a URL.
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?
Looking to populate a view based on part of a URL.
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.location object. From there you just need some string methods.
var objectID = location.pathname.split('/').pop();
.split() will split the path into the fragments separated by / and .pop() will retrieve the last one. Of course, if objectID may not always be the last segment, use the proper (0-based) index to retrieve it from array returned by split.
Another solution that may have better performance (shouldn't really make a difference for this use case), assumes that objectID is the last segment:
var objectID = location.pathname.substring(location.pathname.lastIndexOf('/')+1);