Closed andrerfneves closed 9 years ago
First of all, if it goes about the form, there is no value
attribute in the SELECT
element. You should use the selected
attribute on the OPTION
element instead.
It's hard to tell what is wrong without a reproduction. Could you create repo on GitHub that shows this situation? For me, everything looks properly.
Hm, turns out all I had to do was split these up into individual calls
var text = $('#text').val();
question.set('text', text);
var answer = $('#answer').val();
question.set('answer', answer);
var prova = $('#prova').val();
question.set('prova', prova);
var materia = $("#materia").val();
question.set('materia', materia);
instead of the way before. Not quite sure why it works as such, but at least the data is coming through properly now.
And I was using a focus event on a field, I should've been using a change input
event.
I think the problem was using the focus
event and trying to set all the fields at once in one event. In fact it would be better if you do it the way I did it in the example.
Having the id
attribute of the input named the same as the field of the model you can just set a single field on each change event. You can also validate only this field or entire document if you wish.
Great package. Seems to be working wonderfully in my project up to right now. I'm not quite sure of what I'm doing wrong but if anyone could help me out that'd be great.
This is going to seem like a very long issue but it's really just a lot of snippets of code. I basically have a simple Add Question page to that calls the /question/save Meteor Method on the server after validating and then inserts the document in the collection. For some reason, some of my fields (2 selects, 1 textarea and 1 input) come back as null. Not always the same one too (which makes things worst). I know the method is being called and a document is created (good sign) and I know the jQuery for querying the data from the form is sound. I'm just not sure what is going wrong.
I then have a simple events page on the template
I also have the /question/save method on the server.
Here's my collection
Here's my router:
It should be simple. I don't understand why the data isn't coming through. Through using Mongol all I can see on the db that some values get the data, some get null. They interchange, sometimes getting the first two fields and then the next try only gets the last 2 selects. It's fucking with my brain. What am I doing wrong!?
Any help would be appreciated. Thanks in advance!