You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
i am working on a template to update the user profile. i am using a mixture of simple form and underscore to do this. my forms are updating the right collection (Meteor.user().profile) but they are loading in an odd way.
when a user is first created, the form only shows the update profile button. the rest of the page is empty with the exception of the page title. when i click the button, the forms appear! after this, they are visible to the user permanently. this is odd to me. after the forms appear, they work as they should. what i want is for the forms to appear when the page is loaded!
here is my editprofile template
i am working on a template to update the user profile. i am using a mixture of simple form and underscore to do this. my forms are updating the right collection (Meteor.user().profile) but they are loading in an odd way.
when a user is first created, the form only shows the update profile button. the rest of the page is empty with the exception of the page title. when i click the button, the forms appear! after this, they are visible to the user permanently. this is odd to me. after the forms appear, they work as they should. what i want is for the forms to appear when the page is loaded!
here is my editprofile template
my _profileField template
{{#if isTextField}}
{{#with editprofile}}
{{text_field ../name type=../type required=../required hint=../hint placeholder=../placeholder afterAddon=../afterAddon class="profileField"}}
{{/with}}
{{/if}}
{{#if isTextArea}}
{{#with editprofile}}
{{text_area ../name type=../type required=../required hint=../hint placeholder=../placeholder afterAddon=../afterAddon class="profileField"}}
{{/with}}
{{/if}}
{{#if isCheckbox}}
{{#with profile}}
{{check_box name label=label required=required}}
{{/with}}
{{/if}}
{{#if isFileField }}
{{> file_field object=profile field=name}}
{{/if}}
here is my editsprofile.js
Template.editprofile.helpers({
profileFields: function() {
return [
{ name: "firstName", required: true },
{ name: "lastName", required: true },
{ name: "location", required: false },
{ name: "bio", required: false, type: 'text_area' },
{ name: "url", required: false },
{ name: "googlePlusUrl", required: false },
{ name: "twitterHandle", required: false }
];
}
});
Template.editprofile.events({
'submit form': function(event) {
event.preventDefault();
var data = SimpleForm.processForm(event.target);
Meteor.users.update(Meteor.userId(), {$set: {profile: data}});
}
});
Template._profileField.helpers({
editprofile: function() {
if (Meteor.user()) {
return Meteor.user().profile;
}
},
isTextField: function() {
return this.type !== 'file' && this.type !== 'text_area';
},
isTextArea: function() {
return this.type === 'text_area';
},
isCheckbox: function() {
return this.type === 'checkbox';
},
isFileField: function() {
return this.type === 'file';
}
});
Why do you think the input boxes are not appearing on page load?
thanks!
The text was updated successfully, but these errors were encountered: