elie
July 16, 2015, 5:00pm
1
A user comes to my site at example.com/?referrerCode=XXX . I’d like to use XXX when the user signs up.
When he switches routes though, the query part of the route disappears, and by the time they sign up I’ve lost the referrerCode.
Is there an easy way to get around this problem?
Thanks
nkrisc
July 16, 2015, 5:04pm
2
You could just save it locally in a temporary fashion for the duration of their visit and just reference whenever you need it. You could use a global reactive variable like Session.
elie
July 16, 2015, 5:22pm
3
Yeah. I tried taking that approach.
I was using this pattern from the user-accounts package:
AccountsTemplates.addField({
_id: 'referrerCode',
type: 'hidden'
});
Which expects referrerCode in the query, so was wondering if there was an easy way to keep it in the query.
nkrisc
July 16, 2015, 5:25pm
4
Ah I see. Unfortunately I can’t help then, I’m not that familiar with IR.
elie
July 16, 2015, 5:27pm
5
Well this is the code from the user-accounts-core package that was making it work for me. I’ll just set the field myself from the saved variable.
AT.prototype.atInputRendered = function(){
var fieldId = this.data._id;
var queryKey = this.data.options && this.data.options.queryKey || this.data._id;
var inputQueryVal = Router.current().params.query[queryKey];
if (inputQueryVal)
this.$("input#at-field-" + fieldId).val(inputQueryVal);