Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do you move sibling elements order up/down in prototype 1.5.1?
    text
    copied!<p>I am trying to setup a function to allow moving 'up' and 'down' of a table row in a form. The number of table rows is dynamic -- the user can hit a button to add additional rows. There are multiple fields in each table row. There is a header row and footer row with different class names, hence the check of hasClassName.</p> <p>I first wrote this function successfully for use with Prototype 1.6 before realizing I need for it to work with version 1.5.1. We will be upgrading to the latest version of Prototype when time is available for testing, but I need this to work under the our project's current version.</p> <p>The main problem is that in 1.5 you can't just insert an Element as the content of an insertion. This means I need the HTML of the Element I want to insert. This brings up the issue that when I access the HTML for the element (variable "insertHTML") this is the original HTML and does not include the info entered into the related form elements by the user.</p> <p>Any help would be greatly appreciated.</p> <pre><code>moveDataDef: function(num, dir) { var targRow = $('dataDefItem'+num); var content = targRow.innerHTML; var siblings; var insertHTML = targRow.inspect() + targRow.innerHTML + '&lt;/tr&gt;'; if(dir == 'up') siblings = targRow.previousSiblings(); else siblings = targRow.nextSiblings(); if (siblings[0].hasClassName('dataDefItem')) { targRow.remove(); if(dir == 'up') new Insertion.Before(siblings[siblings.length - 1].id, targRow); else new Insertion.After(siblings[0].id, targRow); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload