If you benefit from web2py hope you feel encouraged to pay it forward by contributing back to society in whatever form you choose!


  • 1
    piemaster21  8 years ago
    This is great, yamandu! Solves the tag input problem nicely. A couple of points:
    • How could this be extended to use an autocomplete field, to encourage reuse of existing/common tags?
    • A tiny bit of sample CSS to render the list output as a horizontal list of 'bubbles' (as most sites with tags have) would make this even better. I'll have to have a play myself later.
    • I changed your key handling code a bit to more cleanly handle end-of-tag input (see below). When the space, comma or enter keys are pressed, it will add the current field contents as a new tag and reset the input field without ugly artefacts (e.g. when you hold down the tab key). Just replace the whole input_user field with (should only be 2 lines):
    inp_user = INPUT(_id=idu,
                     _onkeydown='if(event.keyCode in {32:1, 188:1, 13:1}){v=$(this).val();if(v.length) {addTag(v); parse();}$(this).val(""); return false;}')
    

Commented on:

list:string types do not come yet with pratical dynamic validator and widget so I wrote one. It handles list:string like text tags separated by comma by in a transparent way.

Hosting graciously provided by:
Python Anywhere