Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialparker keller
6,539 Pointsreset form code not working
having trouble with the reset form field not resetting, despite only changing the names to what Aisha specifies ($name, $species, $notes). One thing I am confused on is that in some videos we have things like
var $name = $('#pet-name').val(); var $species = $('#pet-species').val(); var $notes = $('#pet-notes').val();
where val() is included, yet in this video it is gone?? When I try to delete it from my code and use the post a pet form, it just gives me output of [object object], so how is it still working for her despite not having it? Not sure if that is changing the functionality of the form or not, but it definitely is confusing the heck out of me and she does not mention it at all
1 Answer
ymusthof
Front End Web Development Techdegree Student 12,035 PointsHi, Have you thought to add .val() for each var inside $newPet?
var $name = $('#pet-name');
var $species = $('#pet-species');
var $notes = $('#pet-notes');
var $newPet = $(
'<section class="six columns"><div class="card"><p><strong>Name:</strong> ' + $name.val() +
'</p><p><strong>Species:</strong> ' + $species.val() +
'</p><p><strong>Notes:</strong> ' + $notes.val() +
'</p><span class="close">×</span></div></section>'
);
$name.val("");
$species.val("Dog");
$notes.val("");
I think if you don't add .val() for each var inside $newPet, it will return object only without any value.
Thaddeus Papciak
Front End Web Development Techdegree Student 6,722 PointsYeah that works, would have been helpful for this to be pointed out in video. Im starting to feel like this course needs to be updated. I keep running into stuff like this. Im going back and reviewing the videos looking for something I thought I missed. At least its not just me.
parker keller
6,539 Pointsparker keller
6,539 Pointsi should also note that everything else functions fine, just not the form reset functionality (which worked prior to making the code more DRY). also the chrome console provides an error for the update reset form code that states "Uncaught TypeError: $name.val is not a function"