Reputation: 117
I decided rather than using arrays for different parts of the same component of my code I'd just use an object. My issue is that using the map function for an html input, I don't think an array of the multiple inputs is being stored in my object property.
var force = new Object();
$(".form").on('click','#forceButton',function(){
force.mag=$('.newF').map(function(){
return parseFloat($(this).val());
}).get();
});
When this part of the code runs all of my jquery elements disappear including my html canvas which sucks! Should I declare this property earlier? Is there a specific procedure for making an object property an array. Before I just had a normal array equal to the mapping function and it worked fine.
Please let me know what you thing the problem could be!
Upvotes: 0
Views: 96
Reputation: 8781
I assume that '#forceButton' is a submit button, so when you click on it it submits the form and this is why all of your jQuery elements disappear. You should use event.preventDefault and event.stopPropagation in order to prevent submission of the form.
Upvotes: 2