Hi, list

I want to have a widget like a multiplerepeatwidget, but with the possibility of add more widgets. It gets a list of widgets (fields), and creates a table with as many rows as repetitions, each row having one of the widgets I got on the "fields" list. It has too an "add row" button, .... to add new rows :P

the problem I have is that it works fine in Opera and IE, but id doesn't in firefox. When I add a new row, the submit button of the form (which is below the widget) doesn't move down. This is happening in both firefox 2.0 and 1.5.

the code below is the widget source code. The function that add the new row is called "add_increment_row", and it gets an ID to identify the table to be modified


class  RepeatingFields( wdg.RepeatingFieldSet):
  """repite un conjunto de widgets varias veces

  recibe un parĂ¡metro repetitions, entero,
  y una lista de widgets, el conjunto de widgets a replicar
  """
  template="""
  <table xmlns:py="http://purl.org/kid/ns#" id="${field_id}_div">
  <tr><td>
  <table id="${field_id}">
    <tr>
      <th py:for="" in fields" class="fieldlabel" py:content="field.label"></th>
    </tr>
    <tr py:for="" in repetitions">
      <td py:for="" in fields">
          <span py:strip="True" py:content="field.display(value_for(field), **params_for(field))"/>
          <span py:if="error_for(field)" class="fielderror" py:content="error_for(field)" />
          <span py:if="field.help_text" class="fieldhelp" py:content="field.help_text" />
      </td>
    </tr>
  </table></td>
  <td valign="bottom"><input type="button" id="${field_id}_adder" value="A&ntilde;adir"/></td>
  </tr>
  </table>
  """
  def __init__(self, *args, **kw):
    super(RepeatingFields, self).__init__(*args, **kw)

    code = wdg.JSSource("""

function clone_increment(obj) {
 MochiKit.DOM.removeEmptyTextNodes(obj);
 field =obj.firstChild;

 new_field = field.cloneNode(true);
 regex = RegExp('[0-9]+');
 num = parseInt(regex.exec(field.id));
 num = num +1;
 parts_id = field.id.split(regex);
 parts_name = field.name.split(regex);
 new_field.id = parts_id[0] + num.toString() + parts_id[1];
 new_field.name = parts_name[0] + num.toString() + parts_name[1];
 return new_field;
}

function add_increment_row (id_table) {
 table = MochiKit.DOM.getElement(id_table);
 actual_ctr = table.rows.length;
 last_row = table.rows[actual_ctr - 1];
 MochiKit.DOM.removeEmptyTextNodes(last_row);
 objs = map(clone_increment, last_row.cells);
 objs = map(partial(TD, null), objs);
 nrow = table.insertRow(-1);
 appendChildNodes(nrow, objs);
}
        """)
    self._javascript_ = [code]

thanks for your help

Javier Rojas

--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to