I am running Rail 3.2.11. I am working on a simple wiki project because I learn rail and javascript. What I want to do is to store a two-column table in my database, whose content and number of rows can be edited by users, and using jQuery to add the form to a new table row on a button click You can. The table is stored in the form of a hash with hash for each row column. I.e. I'm displaying the table on my page like: and my Node.js file is the following: I do when I click on the" Add Row "button, then I get my confirmation that The onclick incident has been recognized, but the forms have not been added, am I completely coming in the wrong way? It seems like there will be an easy way to go about this kind of way. {"row1" = & gt; {"Head" = & gt; "First column / header content", "tail" = & gt; "Second column / data content"}, "row2" = & gt; {"Head" = & gt; "First column / header content", "tail" = & gt; The part of my _form.html.erb looks like this:
$ (document) .ready (function () {$ ('# header'). ( 'script load') var newIndex = 0 $ ( '# add_table_row'). click (function () {$ ( '. sidebar_img'). append ( 'onclick event active') var prevIndex = newIndex bridesmaid prevRow = $ ( '#node_table_row') newIndex = newIndex + 1 var newRow = prevRow.clone (right) .attr ( 'id', 'node_table_row _' + newIndex) newRow.find ( '# node_table_row_head') attr ({ID :. 'node_table_row_head_ '+ newIndex, name:' node [table] [row '+ newIndex +'] [head] '}) newRow.find (' # node_table_row_tail ') attr ({ID :.' node_table_row_tail _ '+ newIndex, name:' Node [table] [line '+ newindex + "] [Tail] '}) Nirav. After (Prerov)})}};
have you tried using jQuery insertAfter () method? Use jQuery to select the table then use. children (). InsertAfter (newRow);
Comments
Post a Comment