Thanks for your reply, have just implemented it. On Tue, Mar 14, 2017 at 7:37 PM, tonthon <[email protected]> wrote:
> > The Sequence widget has also a min_len attribute > http://docs.pylonsproject.org/projects/deform/en/latest/api. > html#deform.widget.SequenceWidget The 'issue' with min_len is that it is mandated, meaning if I put 3 (for example) the user cannot cancel one out. > > > > However if I don't know ahead of time how many rows I'll need, the > > user will at some point have to add rows. How do I get one of the > > behaviours below (top-most is most preferred):- > > > > 1. As user scans one qrcode and presses 'enter', a new row is > > automatically created. This breaks 'enter-to-submit', but that's okay > > for this case. > > You'll need to add some custom javascript code to perform this behaviour. > > In the case your sequence items are only composed of the qrcode field, > something like this should work : > > $('input[name=qrcode]').keypress(function(event){ > |if(e.which ==13){ > deform.appendSequenceItem(this); > | ||// prevent form submission| > return false; > }| > }); > > Thanks, this certainly worked. Some slight typos but nothing too hard even though I detest javascript generally. This is what I ended up using:- $('input[name="qr_code"]').keypress(function(event) { if (event.keyCode == 13) { deform.appendSequenceItem(this); return false; } }); -- You received this message because you are subscribed to the Google Groups "pylons-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/pylons-discuss/CAGQ70evfztibxAGOf3uQRE4CKgw0ji_CHhY8DXaPPwM1k5jH8w%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
