Topic: [insert_html not working] multiple models in the same form

Hi, here is my problem. I want to create a quiz, containing multiple question, and multiple answers. Classic.
Here is the pastie:

http://pastie.org/706697

You'll see in the pastie, if i remove ligne 53 (in _question partial), I can add questions dynamically by clicking on the ligne 30 (in the new.html.erb)
But as soon as I add ligne 53, I can only add answers by clicking on ligne 53, no questions anymore.
I don't care right now if I can create effectively etc... I just want this javascript to work smile

Thank's by advance railers!

Re: [insert_html not working] multiple models in the same form

Not seeing what the links do?  Do you have a helper for add_question_link?
Also, I don't see the javascript you are talking about?

Re: [insert_html not working] multiple models in the same form

woups, sorry, pastie updated smile

BTW, I think it's the same problem than this one:

http://railsforum.com/viewtopic.php?id=35526

Last edited by Pasta (2009-11-19 18:40:09)

Re: [insert_html not working] multiple models in the same form

Are you getting any javascript errors?

Also read through this - http://railsforum.com/viewtopic.php?pid=91229 and http://github.com/miletbaker/add_nested_fields
Might help.  Pay close attention to the bottom of the first link where it mentions nested children of nested children.

Re: [insert_html not working] multiple models in the same form

Thanks for the links! I read through all topic into the first link, but couldn't find any reference to an exemple or whatever about nested children of nested children. Just at the end of the first post, concerning the fact that... it was far more complicated.

So for my v0.1, i just decided to use a workaround, and i'll look at this dynamic field add later.

For those interested, the workaround is simple, i just fixed the number of answers to a question to 5. Let's say it's the maximum though.
If you guys found where is the problem in my code, just reply here!

See you later smile

Re: [insert_html not working] multiple models in the same form

Yah the first link was just mentioning the complications with the javascript escaping.

This http://stackoverflow.com/questions/1220 … ributesfor says to check here - http://github.com/ryanb/complex-form-examples/tree/deep

Seems like it might help you.