javascript - Adding a list item client-side -


I would say that I am making a full start to rail, so that's right, so it can be clear That i'm missing

I have a web form for editing a list of questions ( & lt; ul & gt; ) Each item has an item in the list. There is a text field and a dropdown for the question text of each question that is to indicate this type of question (multiple choice, true / false, etc.). I want to add the user's ability to add new questions, click on a link and a new text box and dropdown appear as items in the list.

I have not found a very clean way to do this, so I'm sorting it together from various tutorials

  & lt; H1 & gt; Edit Survey: & lt;% = "########================================= ================ {@ Survey.name} "-%> & Lt; / H1> & Lt;% form_for @survey ,: url = & gt; {: Action = & gt; 'Update' ,: ID = & gt; Params [: id]} Do | Survey_form | & Gt%; & Lt; H2 & gt; Title: & lt;% = survey_form.text_field: name% & gt; & Lt; / H2 & gt; & Lt; Ol class = 'question_list' & gt; @ Survey in the & lt;% @ survey Questions% & gt; & Lt;% fields_for "question []". F | | & Gt%; & Lt; Li & gt; & Lt;% = f.text_field: q_text% & gt; & Lt; Br> & Lt;% = Select (: Question ,: q_type, {"True / False" = "gtc:" T "," Multiple Choice "=>" M "})% & gt; & lt; br & gt; ; & Lt; / li & gt; & gt;% end% & gt; & lt;% end% & gt; & lt; / ol> & lt;% = link_to_function "Add another question", update_page { | Page | pages | end_tag: update '% = submit_tag' below, 'empty_question', (render: partial = & gt; 'empty_question', object = & gt; @ question)}%> & Lt; br & gt; & lt;% end% & gt; & lt;% "for form_"% & gt; ending & lt;% = link_to "back", {: verb = & gt; ; 'List'}%>  

I have created another ARB file named _blank_question.erb, which is "I have another question

  
  • LET;% = text_field: question, id, size => 25%> & gt; Lt; br & gt; & lt;% = Select (: Question ,: q_type, {"True / False" = "gt": "T", "Multiple Choice" = & gt; "M"})% & gt; & Lt; Br> & Lt; / Li & gt;
  • The problem is that when I click on the "Add another Question" link, I get the following error in the popup. RJS error:

    TypeError: Object '(element) element in the [[native code]}' insert 'a method in' Insert '[the original code]}' insert ' Do not

    Very little Googling has not done any useful results. Any idea why I am wrong here?

    If you are using the Rail version> 2.3 (which I recommend if you do not do this ), You can see two screencasts:

    Explain clearly what you want to do. The second part is related to the Ajax part, but I really recommend watching both first and second parts, because it builds slowly and it will really help you to clarify many things.

    Generally, the site is one of the best ways to learn about simple or complex rail materials.


    Comments