Skip to content

Commit

Permalink
fixed query parameters lookup to reflect latest changes introduced with
Browse files Browse the repository at this point in the history
  • Loading branch information
splendido committed Sep 29, 2015
1 parent 661ebdc commit f5e0d57
Showing 1 changed file with 2 additions and 15 deletions.
17 changes: 2 additions & 15 deletions lib/templates_helpers/at_input.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,12 @@
*/
'use strict';

AccountsTemplates.atInputRendered = function(){
AccountsTemplates.atInputRendered.push(function(){
var fieldId = this.data._id;
var queryKey = this.data.options && this.data.options.queryKey || fieldId;
var currentR = Router.current();
var inputQueryVal = currentR && currentR.params && currentR.params.query && currentR.params.query[queryKey];
if (inputQueryVal) {
this.$("input#at-field-" + fieldId).val(inputQueryVal);
}

var parentData = Template.currentData();
var state = (parentData && parentData.state) || AccountsTemplates.getState();

if (AccountsTemplates.options.focusFirstInput) {
var firstVisibleInput = _.find(AccountsTemplates.getFields(), function(f){
return _.contains(f.visible, state);
});

if (firstVisibleInput && firstVisibleInput._id === fieldId) {
this.$("input#at-field-" + fieldId).focus();
}
}
};
});

0 comments on commit f5e0d57

Please sign in to comment.