Reputation: 2237
I have a dynamically changing variable from hash with a joint of a json path.
Example:
$(function() {
$(window).bind( 'hashchange', function() {
var hash = window.location.hash.substring(1);
$("#display_content").html(position.hash);
});
$(window).trigger( 'hashchange' );
});
How is it posible to turn the hash
variable into a joint of the json url?
Edit:
By joint i mean a part of a json url: (position.secondposition.content)
so each part seperated by a .
is a joint.
Upvotes: 2
Views: 915
Reputation: 133403
You can use position[hash]
So change your code as
$("#display_content").html(position[hash]);
Upvotes: 3