Autocompleter works by creating new Ajax.Autocompleter object. Each autocomplete field must have own Ajax.Autocompleter object. When you clone you do not create new object, you just clone events from old one. But they must unique.
On Aug 20, 9:31 pm, "[email protected]" <[email protected]> wrote: > I'm cloning javascript events on this part of the script: > > if(newRow[i].nodeName == 'SCRIPT') { > var html = newRow[i].innerHTML; > html = html.replace(/ > FacturaDetalleProductoCodigo/, > "FacturaDetalleProductoCodigo" + counter); > html = html.replace(/ > FacturaDetalleProductoCodigo_autoComplete/, > "FacturaDetalleProductoCodigo_autoComplete" + counter); > html = html.replace(/FacturaDetalleProductoId/ > g, > "FacturaDetalleProductoId" + counter); > html = html.replace(/FacturaDetalleCantidad/, > "FacturaDetalleCantidad" + counter); > html = html.replace(/productos0/g, "productos" > + counter); > newRow[i].innerHTML = html; > } > > It only replaces id so that every input field has a unique name and > ajax calls use these new ids. > > When I clone the node I get this HTML code: > > <input name="data[FacturaDetalle][1][producto_id]" value="" > id="FacturaDetalleProductoId1" type="hidden"> > <label for="FacturaDetalleCantidad">Cantidad</label><input name="data > [FacturaDetalle][1][cantidad]" size="3" onchange="calcularImporte > (this.value, document.getElementById > ('FacturaDetallePrecioUnitario1').value, 'FacturaDetalleImporte1')" > maxlength="11" value="" id="FacturaDetalleCantidad1" type="text"> > <label for="FacturaDetalleProductoCodigo">Clave</label> <input > name="data[FacturaDetalle][producto_codigo]" size="5" > id="FacturaDetalleProductoCodigo1" autocomplete="off" value="" > type="text"> > <div style="display: none;" > id="FacturaDetalleProductoCodigo_autoComplete1" > class="auto_complete"></div> > <script type="text/javascript"> > //<![CDATA[ > new Ajax.Autocompleter('FacturaDetalleProductoCodigo1', > 'FacturaDetalleProductoCodigo_autoComplete1', '/pixcua-su/productos/ > seleccionar', {afterUpdateElement:getProductId}); > //]]> > </script> <script type="text/javascript"> > //<![CDATA[ > new Form.Element.Observer('FacturaDetalleProductoId1', 1, function > (element, value) {new Ajax.Updater('productos1','/pixcua-su/facturas/ > agregarProducto', {asynchronous:true, evalScripts:true, > parameters:Form.Element.serialize('FacturaDetalleProductoId1') > +'&'+Form.Element.serialize('FacturaDetalleCantidad1'), requestHeaders: > ['X-Update', 'productos1']})}) > //]]> > </script> > > <label > for="FacturaDetalleConcepto">Concepto</label><input > name="data[FacturaDetalle][1][concepto]" size="30" maxlength="250" > value="" id="FacturaDetalleConcepto1" type="text"> <label > for="FacturaDetallePrecioUnitario">P.U. <small>(con I.V.A.)</small></ > label><input name="data[FacturaDetalle][1][precio_unitario]" size="6" > onchange="calcularImporte(document.getElementById > ('FacturaDetalleCantidad1').value, this.value, > 'FacturaDetalleImporte1')" value="" id="FacturaDetallePrecioUnitario1" > type="text"> <label > for="FacturaDetalleImporte">Importe</ > label><input name="data[FacturaDetalle][1][importe]" size="6" value="" > id="FacturaDetalleImporte1" type="text"> <input value="+" > onclick="addRow()" type="button"> <input value="-" > onclick="this.parentNode.parentNode.removeChild(this.parentNode);" > type="button"> > > If I copy and paste this code in the view it works well, but not when > it's generated by the script, Am I missing something? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" 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/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---
