javascript - Fetching Data from URL in Meteor -
i'm trying pass data through url in meteor. when console.log object empty, however, when refresh page, object displayed correctly in console.log.
i have button in google maps infowindow has href page , parameters want pass over.
js.
var infowindow = new google.maps.infowindow({ content: '<div id="infowin"><p>'+name+'"s storage </p>' + 'space: '+space+ '<p>price: '+price+'<div><a href="/request_storage?name='+name+'" class="btn btn-primary btn-lg" role="button">request storage</a></div>' + });
in template try access data :
js.
template.storagerequest.oncreated(function () { // use this.subscribe inside oncreated callback var = {}; var query = window.location.search.substring(1).split("&"); (var = 0, max = query.length; < max; i++) { if (query[i] === "") // check trailing & no param continue; var param = query[i].split("="); get[decodeuricomponent(param[0])] = decodeuricomponent(param[1] || ""); } template.storagerequest.requestdata = get; });
any appreciated
Comments
Post a Comment